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 83/ 160
05. Data Lakehouses & Open Table Formats

Object Storage Partitioning (Hive-Style Partitioning) & The Small Files Problem

Partition by high-cardinality-safe keys and compact tiny files that destroy list and read performance.

IntermediateHive Partitions · Small Files · Compaction3 quiz questions
Practice Generative AI Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Common keys and cardinality. Next, only useful explicit partitions. Finally, merge tiny files and update table atomically.

Think of it like…

A partition is a warehouse aisle; a useful aisle groups common queries, but an aisle per screw makes the catalog huge and the picker spend all day opening doors.

Where you’ve seen it

Write dt=2026-11-21/region=ap-south with 256–512 MB data files; a user_id partition with 50 million prefixes is replaced by a bucket/hidden hash transform or an Iceberg sort order.

Words you’ll hear

Hive Partitions
Directory paths of column=value pairs interpreted as table partition values by Hive-compatible readers.
Small Files
Files far below the engine's efficient object-read scale, causing excess metadata and open/list overhead.
Compaction
A transactional rewrite that combines small data files while updating table snapshots so readers see old or new complete state.
Operational boundary
Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning. Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

Visual diagram

Loading interactive diagram

Theory & deep dive

Hive Partitions: the working mechanism

Hive-style directory keys such as dt=.../region=... let engines prune object prefixes, but the key's cardinality and one file per task can easily create millions of tiny files.

Common keys and cardinality. Only useful explicit partitions, then bounded tasks and target file bytes; this exposes the state governed by Compaction.

Object Storage Partitioning & The Small Files Problem in one concrete design

Write dt=2026-11-21/region=ap-south with 256–512 MB data files; a user_id partition with 50 million prefixes is replaced by a bucket/hidden hash transform or an Iceberg sort order.

Key takeaway: Hive-style directory keys such as `dt=

Object Storage Partitioning & The Small Files Problem: failure mode and production response

Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.

Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning. Track Partition cardinality as "keep far below the number of expected rows per common query", and make Target file visible to the dataset owner.

Key takeaway: Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

How it works, step by step

Step 1 of 4
Hive Partitions

1. Profile filters

Common keys and cardinality. Hive-style directory keys such as dt=.../region=... let engines prune object prefixes, but the key's cardinality and one file per task can easily create millions of tiny files.

common keys and cardinality
Key numbers at this step
Partition cardinality
keep far below the number of expected rows per common query
Small Files
Files far below the engine's efficient object-read scale, causing excess metadata and open/list overhead.

When to use it & trade-offs

What it is

Hive-style directory keys such as dt=.../region=... let engines prune object prefixes, but the key's cardinality and one file per task can easily create millions of tiny files. Write dt=2026-11-21/region=ap-south with 256–512 MB data files; a user_id partition with 50 million prefixes is replaced by a bucket/hidden hash transform or an Iceberg sort order.

Why it matters: Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning. Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

When to reach for it

  • Partition by high-cardinality-safe keys and compact tiny files that destroy list and read performance.
  • Choose Hive Partitions because it provides this capability: Directory paths of column=value pairs interpreted as table partition values by Hive-compatible readers.
  • Keep evidence for Partition cardinality at "keep far below the number of expected rows per common query" so the last production stage-Compact - merge tiny files and update table atomically-remains testable.

When to avoid or be careful

  • Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.
  • Do not conflate Small Files with Hive Partitions. The second concept contributes different behavior: Files far below the engine's efficient object-read scale, causing excess metadata and open/list overhead.
  • Release only after this guardrail is in place: Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

Hive Partitions / Small Files / Compaction - roles, limits, and operating cost

Hive Partitions
Best for: Directory paths of column=value pairs interpreted as table partition values by Hive-compatible readers.

Strengths: Directory paths of column=value pairs interpreted as table partition values by Hive-compatible readers. Hive-style directory keys such as `dt=.

Watch out: Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.

Small Files
Best for: Files far below the engine's efficient object-read scale, causing excess metadata and open/list overhead.

Strengths: Files far below the engine's efficient object-read scale, causing excess metadata and open/list overhead. In this workflow it supports: Write - bounded tasks and target file bytes.

Watch out: The operating cost is real: typically 128–1,024 MB depending on object and engine.

Compaction
Best for: A transactional rewrite that combines small data files while updating table snapshots so readers see old or new complete state.

Strengths: A transactional rewrite that combines small data files while updating table snapshots so readers see old or new complete state. Its output can be checked with File count/query.

Watch out: Operating guardrail: Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

Interview signals & numbers to know

When this topic comes up

  • “Where is the failure boundary for Hive Partitions, and how would Partition cardinality reveal it?”
  • “Why is Small Files distinct from this behavior: a transactional rewrite that combines small data files while updating table snapshots so readers see old or new complete state?”
  • Production clue: Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.
  • Design probe: Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

Benchmarks & rules of thumb

Partition cardinality -
keep far below the number of expected rows per common query
Target file -
typically 128–1,024 MB depending on object and engine
File count/query -
metadata and open operations must be bounded by pruning

Common mistakes & follow-ups

Common interview mistakes

  • Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.
  • Reporting success from a job exit code without checking Partition cardinality and Target file.
  • Treating this example as complete without replay, rollback, or access boundaries: Write dt=2026-11-21/region=ap-south with 256–512 MB data files; a user_id partition with 50 million prefixes is replaced by a bucket/hidden hash transform or an Iceberg sort order.

Likely interviewer follow-ups

  • How would you prove this contract instead of only checking that the command ran: Directory paths of column=value pairs interpreted as table partition values by Hive-compatible readers.
  • What does the recovery plan do when this occurs? Partitioning by user_id creates a directory per high-cardinality value, while a high parallelism streaming writer emits thousands of sub-megabyte files that make listing and open/read overhead exceed useful scanning.
  • When is Hive Partitions insufficient for Target file, and what does adding Small Files cost in Partition cardinality?
Interview tip: Lead with the data path and failure boundary: Hive-style directory keys such as dt=.../region=... let engines prune object prefixes, but the key's cardinality and one file per task can easily create millions of tiny files. Then make the answer operational: Choose low-to-moderate-cardinality frequent-filter keys, avoid redundant nested date fields, rewrite/compact with a target compressed file size, and rely on table-format clustering/hidden partitions for finer pruning.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Object Storage Partitioning (Hive-Style Partitioning) & The Small Files Problem with data engineer interview Q&A and hands-on practice.

Open Data Engineer Q&A →Machine Learning Q&A
Previous topic
Cloud Object Storage Fundamentals (AWS S3, GCS, Azure Blob Storage)
Next topic
Limitations of Traditional Hive Tables (Lack of ACID, Schema Evolution Issues)