What is Hive partitioning?
Hive partitioning is a way of laying out data files in folders named key=value, such as event_date=2026-11-23/, so the partition value is part of the path. Query engines turn those folder names into columns and skip every folder that a filter rules out.
How it works
The convention comes from Apache Hive. Spark, Trino, Athena, BigQuery external tables and DuckDB all read it. A dataset partitioned by date and country looks like this:
events/ event_date=2026-11-22/country=DE/data_0.parquet event_date=2026-11-22/country=US/data_0.parquet event_date=2026-11-23/country=US/data_0.parquet
The partition columns usually aren't stored inside the files; the engine reads them from the path. A filter on event_date is checked against folder names before any file is opened. That makes it a form of predicate pushdown that also works for CSV and JSON, which have no statistics of their own.
Writing and reading partitions in DuckDB
COPY (
SELECT range AS event_id,
range % 50000 AS user_id,
['view', 'click', 'purchase'][(range // 90) % 3 + 1] AS event_type,
DATE '2026-01-01' + (range % 90)::INT AS event_date
FROM range(5_000_000)
) TO 'events' (FORMAT parquet, PARTITION_BY (event_date));
-- One folder per day: events/event_date=2026-01-01/data_0.parquet, ...
SELECT count(*) AS files FROM glob('events/*/*.parquet');
SELECT event_type, count(*) AS events
FROM read_parquet('events/*/*.parquet', hive_partitioning = true)
WHERE event_date = DATE '2026-02-14'
GROUP BY event_type
ORDER BY event_type;
-- The plan reports "Scanning Files: 1/90"
EXPLAIN
SELECT count(*)
FROM read_parquet('events/*/*.parquet', hive_partitioning = true)
WHERE event_date = DATE '2026-02-14';COPY writes 90 folders, one file each. DuckDB reads event_date back as a DATE, inferred from the folder names. The date filter opens 1 of the 90 files and returns 55,556 events. A filter on user_id = 42 has no folder to match, so it reads all 90.
Choosing a partition key
- Partition on what most queries filter by, usually a date. A key nobody filters on only adds files.
- Keep the number of partitions low. In the example, 5 million rows over 90 days already gave files of about 340 KB, and on object storage every file is a separate request. One folder per user or order ID creates millions of tiny files.
- Queries must filter on the partition column itself. If folders hold event_date and the query filters on an event_ts timestamp column, no folder is skipped.
- Changing the scheme means rewriting the data.
- Auto-detection can surprise you. When a path looks like key=value, DuckDB may add the folder as a column, so SELECT * returns one more column than the files hold. Pass hive_partitioning = false when you don't want it.
Apache Iceberg addresses the last three with hidden partitioning: a table partitioned by day(event_ts) prunes on a filter against event_ts, and the partition spec can change without rewriting old files.
In Thunderduck
In S3, GCS, Azure and R2 catalogs, partitioned layouts work with read_parquet, read_csv and read_json, and the partition keys come back as columns. The Files page marks key=value folders as Hive-partitioned, and opening a file from one in Studio adds hive_partitioning=true. A filter on a partition column is what keeps a large folder cheap to query.
Exports can build partition folders over time. Path templates such as 'raw_files/events/year={year}/month={month}/day={day}/events.parquet' put each run's file in the folder for its UTC date. The folder comes from the clock, not from the rows, and the PARTITION_BY option itself is refused for exports.
Docs: https://docs.thunderduck.ai/catalogs/object-storage/