Line 1: |
Line 1: |
| The OFF database contains a variety of data in different format, such as '''TEXTS, LISTS, STRUCT, DATES''', and even more... | | The OFF database contains a variety of data in different format, such as '''TEXTS, LISTS, STRUCT, DATES''', and even more... |
| | | |
− | But no worries, '''DuckDB''' handles any type of data! '''Learn how to use the database by solving the most common use-cases asked by the community:''' | + | But no worries, '''DuckDB''' handles any type of data! Learn how to use the database by solving the most common use-cases asked by the community. |
| | | |
− | * '''Display product name (for main language) of all products of with category en:butters'''.
| + | '''Display product name (for main language) of all products of with category en:butters''' |
| | | |
| SELECT | | SELECT |
Line 15: |
Line 15: |
| list_contains (categories_tags, 'en:milks') | | list_contains (categories_tags, 'en:milks') |
| LIMIT | | LIMIT |
− | 10;'; | + | 10; |
| + | ┌───────────────┬─────────────────────────────────────────────────────────────────────┐ |
| + | │ code │ unnest(list_filter(product_name, (x -> (x.lang = 'main'))))['text'] │ |
| + | │ varchar │ varchar │ |
| + | ├───────────────┼─────────────────────────────────────────────────────────────────────┤ |
| + | │ 0011110807625 │ Quality food centers, salted butter │ |
| + | │ 0011110808998 │ Unsalted Butter │ |
| + | │ 0011110842640 │ Ralphs, Salted Sticks, Butter │ |
| + | │ 0011110852878 │ Salted butter │ |
| + | │ 0011110854384 │ Qfc, unsalted butter │ |
| + | │ 0011110862600 │ King Soopers City Market, Salted Butter │ |
| + | │ 0011110863256 │ Salted Butter │ |
| + | │ 0011110863270 │ Unsalted Butter │ |
| + | │ 0011110893017 │ Salted Butter │ |
| + | │ 0011110893055 │ Unsalted butter sticks │ |
| + | ├───────────────┴─────────────────────────────────────────────────────────────────────┤ |
| + | │ 10 rows 2 columns │ |
| + | └─────────────────────────────────────────────────────────────────────────────────────┘ |
| | | |
− | ┌───────────────┬─────────────────────────────────────────────────────────────────────┐
| + | '''Who are the biggest contributors?''' |
− | │ code │ unnest(list_filter(product_name, (x -> (x.lang = 'main'))))['text'] │
| |
− | │ varchar │ varchar │
| |
− | ├───────────────┼─────────────────────────────────────────────────────────────────────┤
| |
− | │ 0011110807625 │ Quality food centers, salted butter │
| |
− | │ 0011110808998 │ Unsalted Butter │
| |
− | │ 0011110842640 │ Ralphs, Salted Sticks, Butter │
| |
− | │ 0011110852878 │ Salted butter │
| |
− | │ 0011110854384 │ Qfc, unsalted butter │
| |
− | │ 0011110862600 │ King Soopers City Market, Salted Butter │
| |
− | │ 0011110863256 │ Salted Butter │
| |
− | │ 0011110863270 │ Unsalted Butter │
| |
− | │ 0011110893017 │ Salted Butter │
| |
− | │ 0011110893055 │ Unsalted butter sticks │
| |
− | ├───────────────┴─────────────────────────────────────────────────────────────────────┤
| |
− | │ 10 rows 2 columns │
| |
− | └─────────────────────────────────────────────────────────────────────────────────────┘
| |
| | | |
− | * '''Who are the biggest contributors?'''
| + | ''Ex: Top 10 best contributors in OFF'' |
| | | |
− | ''Ex: Top 10 best contributors in OFF''
| |
| SELECT creator, count(*) AS count | | SELECT creator, count(*) AS count |
| FROM read_parquet('food.parquet') | | FROM read_parquet('food.parquet') |
Line 61: |
Line 61: |
| └──────────────────────────────────────┘ | | └──────────────────────────────────────┘ |
| | | |
− | ===== DATE & ARRAY fields =====
| + | '''Number of added products per year''' |
− | | |
− | * '''Number of added products per year'''
| |
| | | |
| --entry_dates_tags is a list of texts. We take the value at position 3: the year | | --entry_dates_tags is a list of texts. We take the value at position 3: the year |
Line 93: |
Line 91: |
| └──────────────────┘ | | └──────────────────┘ |
| | | |
− | * '''How many images where uploaded in 2024?'''
| + | '''How many images where uploaded in 2024?''' |
| | | |
| SELECT | | SELECT |
Line 110: |
Line 108: |
| 'food.parquet' | | 'food.parquet' |
| ); | | ); |
− | | + | ┌─────────────┐ |
− | ┌─────────────┐ | + | │ image_count │ |
− | │ image_count │ | + | │ int128 │ |
− | │ int128 │ | + | ├─────────────┤ |
− | ├─────────────┤ | + | │ 716207 │ |
− | │ 716207 │ | + | └─────────────┘ |
− | └─────────────┘ | |