df-drills pandas · Polars · DuckDB SQL · DuckDB Relational 题目列表 登录

展开标签

简单 18-nested 列表与结构体 explodeunnestlist

把每篇文章的标签列表展开:每个 (article_id, 标签) 一行。

  • 空列表和 null 列表都不产生任何行。
  • 同一篇文章里重复出现的标签照样输出多行(不去重),大小写也保持原样。
  • 列表里的元素本身不会是 null。

输入

  • articles(article_id, title, author, tags, published_at, word_count):tags 是字符串列表,可能为空列表或 null

输出

列为 article_id, tag,行顺序不限。

输入表 (case base,共 2 个 case:base、edge)

articles blog/articles
#article_idint64titlestringauthorstruct<name: string, country: string>tagslist<string>published_atdatetimeword_countint64
1 1 A gentle intro to DuckDB {"name": "Hans Muller", "country": "DE"} ["etl", "Python", "rust"] 2026-02-07 18:20:00 353
2 2 Testing Python {"name": "Bob Smith", "country": "US"} ["SQL"] 2026-09-02 17:13:00 3726
3 3 10 tips for dataframes {"name": "Bob Smith", "country": "US"} ["pandas"] 2026-07-23 20:39:00 362
4 4 Debugging DuckDB {"name": "Amy Chen", "country": "US"} [] 2026-01-20 22:03:00 3845
5 5 Debugging window functions {"name": "Ana Souza", "country": "BR"} [] 2026-08-20 10:17:00 3899
6 6 Getting started with Polars {"name": "王芳", "country": "CN"} ["polars"] 2026-05-17 19:28:00 2086
7 7 Testing dataframes {"name": "Ana Souza", "country": "BR"} ["rust", "ml", "go"] 2026-08-01 17:58:00 1251
8 8 Benchmarking pandas {"name": "王芳", "country": "CN"} ["Python", "pandas", "ml", "go"] 2026-02-27 20:10:00 2984
9 9 Benchmarking Python {"name": "Hans Muller", "country": "DE"} ["etl"] 2026-09-09 09:30:00 1709
10 10 10 tips for dataframes {"name": "Amy Chen", "country": "US"} null 2026-08-11 21:07:00 2000
11 11 Debugging pandas {"name": "Amy Chen", "country": "US"} ["python", "viz"] 2026-06-23 17:24:00 3908
12 12 Getting started with SQL {"name": "Ana Souza", "country": "BR"} ["sql"] 2026-03-01 18:14:00 2493
13 13 Common pitfalls in SQL {"name": "Li Wei", "country": "CN"} ["python", "pandas", "python"] 2026-03-25 19:46:00 473
14 14 A gentle intro to ETL {"name": "王芳", "country": "CN"} ["viz", "SQL", "etl", "go"] 2026-07-21 18:59:00 3850
15 15 Common pitfalls in Python {"name": "Amy Chen", "country": "US"} ["SQL", "polars"] 2026-06-08 15:27:00 1357
16 16 Getting started with ETL {"name": "Ana Souza", "country": "BR"} ["rust", "ml", "python"] 2026-07-16 18:30:00 2713
17 17 A gentle intro to pandas {"name": "Kenji Sato", "country": "JP"} ["Python", "ml"] 2026-05-27 20:35:00 2305
18 18 Getting started with pandas {"name": "Li Wei", "country": "CN"} null 2026-06-17 11:01:00 1790
19 19 A gentle intro to ETL {"name": "Kenji Sato", "country": "JP"} ["duckdb", "SQL", "viz"] 2026-02-27 21:10:00 3630
20 20 Benchmarking DuckDB {"name": "Li Wei", "country": "CN"} ["Python", "duckdb"] 2026-05-07 13:35:00 1067
显示前 20 行,共 40 行

期望输出 (case base,行顺序不限)

#article_idInt64tagString
1 1 etl
2 1 Python
3 1 rust
4 2 SQL
5 3 pandas
6 6 polars
7 7 rust
8 7 ml
9 7 go
10 8 Python
11 8 pandas
12 8 ml
13 8 go
14 9 etl
15 11 python
16 11 viz
17 12 sql
18 13 python
19 13 pandas
20 13 python
21 14 viz
22 14 SQL
23 14 etl
24 14 go
25 15 SQL
26 15 polars
27 16 rust
28 16 ml
29 16 python
30 17 Python
31 17 ml
32 19 duckdb
33 19 SQL
34 19 viz
35 20 Python
36 20 duckdb
37 21 ml
38 21 Python
39 22 polars
40 22 rust
41 22 etl
42 23 sql
43 23 duckdb
44 23 sql
45 23 SQL
46 24 duckdb
47 25 python
48 25 viz
49 26 SQL
50 26 polars
显示前 50 行,共 74 行