Interview's MateData Engineer
Interview's Mate

Data Engineer

SQL · Spark · Lakehouse · Streaming

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Data Engineer topics
Lesson 12/ 160
01. Data Engineering Foundations, Python & Linux

Querying Local Files at Lightning Speed with DuckDB

Run analytical SQL directly on local Parquet/CSV with DuckDB for fast exploration and light transforms.

IntermediateDuckDB · SQL on Files · Parquet3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

File, glob, HTTP, or object store. Next, explicit types for CSV and JSON. Finally, sorted, compressed Parquet with row checks.

Think of it like…

DuckDB is a high-speed analytical workbench bolted directly to the files, whereas a warehouse is an entire shared factory with operators, queues, and admission control.

Where you’ve seen it

duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.

Words you’ll hear

DuckDB
An embedded OLAP engine process that stores and executes analytical SQL close to the application.
SQL on Files
DuckDB's table functions that expose files such as read_parquet() as relational inputs without a load step.
Parquet
A path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown.
Operational boundary
It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling. Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

Visual diagram

Loading interactive diagram

Theory & deep dive

DuckDB: the working mechanism

DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.

File, glob, HTTP, or object store. Explicit types for CSV and JSON, then filters, joins, aggregates; this exposes the state governed by Parquet.

Querying Local Files at Lightning Speed with DuckDB in one concrete design

duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.

Key takeaway: DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service

Querying Local Files at Lightning Speed with DuckDB: failure mode and production response

It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.

Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks. Track Memory bound as "configure a fraction of host RAM with memory_limit", and make Vector size visible to the dataset owner.

Key takeaway: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

How it works, step by step

Step 1 of 4
DuckDB

1. Register input

File, glob, HTTP, or object store. DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.

file, glob, HTTP, or object store
Key numbers at this step
Memory bound
configure a fraction of host RAM with `memory_limit`
SQL on Files
DuckDB's table functions that expose files such as `read_parquet()` as relational inputs without a load step.

When to use it & trade-offs

What it is

DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service. duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.

Why it matters: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling. Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

When to reach for it

  • Run analytical SQL directly on local Parquet/CSV with DuckDB for fast exploration and light transforms.
  • Choose DuckDB because it provides this capability: An embedded OLAP engine process that stores and executes analytical SQL close to the application.
  • Keep evidence for Memory bound at "configure a fraction of host RAM with memory_limit" so the last production stage-Publish - sorted, compressed Parquet with row checks-remains testable.

When to avoid or be careful

  • It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
  • Do not conflate SQL on Files with DuckDB. The second concept contributes different behavior: DuckDB's table functions that expose files such as read_parquet() as relational inputs without a load step.
  • Release only after this guardrail is in place: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

DuckDB / SQL on Files / Parquet - roles, limits, and operating cost

DuckDB
Best for: An embedded OLAP engine process that stores and executes analytical SQL close to the application.

Strengths: An embedded OLAP engine process that stores and executes analytical SQL close to the application. DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service.

Watch out: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.

SQL on Files
Best for: DuckDB's table functions that expose files such as read_parquet() as relational inputs without a load step.

Strengths: DuckDB's table functions that expose files such as read_parquet() as relational inputs without a load step. In this workflow it supports: Run vectorized SQL - filters, joins, aggregates.

Watch out: The operating cost is real: typically about 2,048 values per vector batch.

Parquet
Best for: A path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown.

Strengths: A path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown. Its output can be checked with Concurrency.

Watch out: Operating guardrail: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

Interview signals & numbers to know

When this topic comes up

  • “Where is the failure boundary for DuckDB, and how would Memory bound reveal it?”
  • “Why is SQL on Files distinct from this behavior: a path to immutable columnar batches on local or object storage, often yielding predicate and projection pushdown?”
  • Production clue: It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
  • Design probe: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

Benchmarks & rules of thumb

Memory bound -
configure a fraction of host RAM with `memory_limit`
Vector size -
typically about 2,048 values per vector batch
Concurrency -
single-node CPU and I/O are shared by all attached readers/writers

Common mistakes & follow-ups

Common interview mistakes

  • It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
  • Reporting success from a job exit code without checking Memory bound and Vector size.
  • Treating this example as complete without replay, rollback, or access boundaries: duckdb -c "COPY (SELECT * FROM read_parquet('s3://lake/orders/dt=2026-11-20/*.parquet') WHERE status='paid') TO 'paid.parquet' (FORMAT PARQUET, COMPRESSION ZSTD);" performs a single-node ELT.

Likely interviewer follow-ups

  • How would you prove this contract instead of only checking that the command ran: An embedded OLAP engine process that stores and executes analytical SQL close to the application.
  • What does the recovery plan do when this occurs? It is not automatically a shared multi-tenant server: queries compete for the host's memory, glob paths can pull unintended historical partitions, and a fast local prototype can conceal object-store throttling.
  • When is DuckDB insufficient for Vector size, and what does adding SQL on Files cost in Memory bound?
Interview tip: Lead with the data path and failure boundary: DuckDB is an in-process columnar SQL engine that can scan Parquet, CSV, JSON, and Arrow directly, using vectorized execution and multi-core parallelism without a warehouse service. Then make the answer operational: Set memory_limit, threads, and temp_directory; pin exact globs and schemas; spill oversized sorts to disk; and export deterministic Parquet partitions with explicit row-count and checksum checks.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Querying Local Files at Lightning Speed with DuckDB with data engineer interview Q&A and hands-on practice.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Reading & Writing Data with Pandas & Polars (Lazy Execution)
Next topic
REST API Ingestion, Pagination, Rate Limiting & Retries