Working with File Formats (CSV, JSON, XML, Parquet, Avro, ORC)
Pick and parse the right interchange format for batch, streaming, and analytical workloads.
In plain words
Append rows or scan columns. Next, required fields, types, and evolution. Finally, reader round-trip, counts, and compatibility.
Think of it like…
A file format is packaging: envelopes are easy to inspect, palletized boxes are efficient in bulk, and a manifest inside each crate tells an automated warehouse how to unpack it.
Where you’ve seen it
Kafka events use Avro with a registry subject and BACKWARD compatibility; a daily append lands as Snappy Parquet partitioned by event_date, while APIs exchange newline-delimited JSON for debugging.
Words you’ll hear
- Parquet
- A columnar format with encoding statistics and predicate pushdown, commonly the default for analytical object storage.
- Avro
- A compact row-oriented format with an embedded schema that is natural for Kafka records and serialization contracts.
- JSON
- A text format that is human-readable and broadly accepted, but has no native decimal distinction and often no schema by itself.
- Operational boundary
- CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates. Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets.
Visual diagram
Theory & deep dive
Parquet: the working mechanism
File format selection is a contract between producer and consumer: CSV and JSON maximize interchange simplicity, Parquet and ORC optimize column scans, and Avro carries row-oriented schemas well for streams.
Append rows or scan columns. Required fields, types, and evolution, then date, decimal, null, and binary semantics; this exposes the state governed by JSON.
Kafka events use Avro with a registry subject and BACKWARD compatibility; a daily append lands as Snappy Parquet partitioned by event_date, while APIs exchange newline-delimited JSON for debugging.
Working with File Formats: failure mode and production response
CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets. Track Parquet batch as "often 128 MiB–1 GiB logical target files", and make Avro unit visible to the dataset owner.
How it works, step by step
Step 1 of 41. Identify workload
Append rows or scan columns. File format selection is a contract between producer and consumer: CSV and JSON maximize interchange simplicity, Parquet and ORC optimize column scans, and Avro carries row-oriented schemas well for streams.
- Parquet batch
- often 128 MiB–1 GiB logical target files
- Avro
- A compact row-oriented format with an embedded schema that is natural for Kafka records and serialization contracts.
When to use it & trade-offs
What it is
File format selection is a contract between producer and consumer: CSV and JSON maximize interchange simplicity, Parquet and ORC optimize column scans, and Avro carries row-oriented schemas well for streams. Kafka events use Avro with a registry subject and BACKWARD compatibility; a daily append lands as Snappy Parquet partitioned by event_date, while APIs exchange newline-delimited JSON for debugging.
Why it matters: CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates. Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets.
When to reach for it
- Pick and parse the right interchange format for batch, streaming, and analytical workloads.
- Choose Parquet because it provides this capability: A columnar format with encoding statistics and predicate pushdown, commonly the default for analytical object storage.
- Keep evidence for Parquet batch at "often 128 MiB–1 GiB logical target files" so the last production stage-Validate - reader round-trip, counts, and compatibility-remains testable.
When to avoid or be careful
- CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
- Do not conflate Avro with Parquet. The second concept contributes different behavior: A compact row-oriented format with an embedded schema that is natural for Kafka records and serialization contracts.
- Release only after this guardrail is in place: Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets.
Parquet / Avro / JSON - roles, limits, and operating cost
Strengths: A columnar format with encoding statistics and predicate pushdown, commonly the default for analytical object storage. File format selection is a contract between producer and consumer: CSV and JSON maximize interchange simplicity, Parquet and ORC optimize column scans, and Avro carries row-oriented schemas well for streams.
Watch out: CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
Strengths: A compact row-oriented format with an embedded schema that is natural for Kafka records and serialization contracts. In this workflow it supports: Encode - date, decimal, null, and binary semantics.
Watch out: The operating cost is real: one object schema plus many appended records.
Strengths: A text format that is human-readable and broadly accepted, but has no native decimal distinction and often no schema by itself. Its output can be checked with Validation.
Watch out: Operating guardrail: Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets.
Interview signals & numbers to know
When this topic comes up
- “Where is the failure boundary for Parquet, and how would Parquet batch reveal it?”
- “Why is Avro distinct from this behavior: a text format that is human-readable and broadly accepted, but has no native decimal distinction and often no schema by itself?”
- Production clue: CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
- Design probe: Choose the format by access pattern, define schema and compatibility rules, write checksums and row counts, and use Parquet/ORC with a schema registry or manifest for analytical datasets.
Benchmarks & rules of thumb
- Parquet batch
- often 128 MiB–1 GiB logical target files
- Avro unit
- one object schema plus many appended records
- Validation
- row count, schema fingerprint, and checksum retained per file
Common mistakes & follow-ups
Common interview mistakes
- CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
- Reporting success from a job exit code without checking Parquet batch and Avro unit.
- Treating this example as complete without replay, rollback, or access boundaries: Kafka events use Avro with a registry subject and
BACKWARDcompatibility; a daily append lands as Snappy Parquet partitioned byevent_date, while APIs exchange newline-delimited JSON for debugging.
Likely interviewer follow-ups
- How would you prove this contract instead of only checking that the command ran: A columnar format with encoding statistics and predicate pushdown, commonly the default for analytical object storage.
- What does the recovery plan do when this occurs? CSV silently loses type information and new delimiters break quoted fields; JSON schema drift is hard to compact, while Parquet is efficient for analytics but awkward for single-row updates.
- When is Parquet insufficient for Avro unit, and what does adding Avro cost in Parquet batch?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Working with File Formats (CSV, JSON, XML, Parquet, Avro, ORC) with data engineer interview Q&A and hands-on practice.