DT4: Streams, big data and file formats

Lesson 5 of 5 · reading 15–25 minutes; practice and project time is on the module page

File formats and data lakes

🎯You'll be able to

Choose between CSV, JSON and Parquet, store large data in partitioned folders, and explain what table formats such as Delta Lake and Iceberg add.

🏠The everyday picture

A library shelves books by subject and then by author, so you walk to one shelf instead of searching every room. Partitioned, columnar files do the same for a query.

📘What it really is

📝A worked example

Input: export SabziSathi's cleaned order lines three ways with DuckDB:

copy (select * from clean.order_lines) to 'lines.csv' (header);
copy (select * from clean.order_lines) to 'lines.parquet' (format parquet);
copy (select * from clean.order_lines) to 'by_day' (format parquet, partition_by (order_date));

Then explain analyze select count(*) from read_parquet('by_day/*/*.parquet', hive_partitioning=true) where order_date = '2026-10-05'.

Expected output: the CSV is about 1.28 MB and the single Parquet file about 164 KB, roughly eight times smaller. The partitioned query reads 1 of 30 files ("Scanning Files: 1/30") and counts 302 lines. Measured on 1 November 2026 with DuckDB 2.0.0.

🌍Where it's used

📝Case scenario

An analytics team paid for a query engine by the amount of data scanned. Their event data was one folder of CSV files. Converting to Parquet partitioned by day cut a typical query from scanning 2 TB to about 20 GB, and the monthly bill fell with it.

🖱️Try it

Run the worked example in the kit (inside python -c "import duckdb; ...", or the DuckDB command line). Then query one store's revenue from the single Parquet file and look at the plan's "Data Read". Success: you have the two file sizes and can point to "1/30" in the plan.

⚠️Common mistakes

🛠️For your project

Not in the kit's tests. The capstone's warehouse design notes ask which tables you'd partition, and by what.

✅Quick check

Why is Parquet faster to query than CSV?

Show the answer

It's columnar and compressed, so a query reads only the columns it needs, with types already known.

What does partition pruning do?

Show the answer

It skips folders that can't match the filter.

← PreviousSpark and when you need a cluster
ProLearners Assist