Data Ingestion and Transformation · Topic 3 of 8
File Formats and Compression
Compare CSV, JSON, Avro, Parquet and ORC and the main compression codecs, and learn how format, file size and partitioning affect cost and speed on AWS.
- 4 min
- Parquet and ORC are columnar and the usual choice for analytics. CSV and JSON are row based text.
- Avro stores its schema with the data and suits streaming and schema evolution.
- Columnar formats cut the data scanned, which lowers Athena cost and speeds up queries.
What it is
The format and layout of files in Amazon S3 decide how fast and how cheaply you can query them. A good transformation step often does nothing more than convert raw files into a better format.
Data engineers describe a workload by the three Vs. Volume is how much data there is, velocity is how fast it arrives, and variety is how many shapes it has (structured, semi structured and unstructured).
How it works
Row based and columnar formats
A row based format stores each record together. A columnar format stores each column together, so a query that needs three columns out of fifty reads only those three.
| Format | Layout | Typical use |
|---|---|---|
| CSV (comma separated values) | Row, text | Simple exchange, no types or schema inside |
| JSON (JavaScript Object Notation) | Row, text | Nested and semi structured data, APIs, logs |
| Avro | Row, binary, schema stored with the data | Streaming and write heavy pipelines, schema evolution |
| Parquet | Columnar, binary | Analytics in Athena, Redshift Spectrum, EMR, Glue |
| ORC (Optimized Row Columnar) | Columnar, binary | Analytics, common in Hive style workloads |
Parquet and ORC keep column statistics and apply good compression. Engines use them to skip data that cannot match a filter. These are the default answer when a scenario says "reduce the amount of data scanned" or "analytical queries on S3".
Compression
Compression reduces storage and the bytes read from S3. The trade off is CPU time and whether a file can be split, because a splittable file lets many workers read different parts of one file in parallel.
| Codec | Notes |
|---|---|
| gzip | Good ratio, but a plain gzip text file is not splittable |
| Snappy | Fast, lower ratio, common default inside Parquet |
| ZSTD | Good balance of ratio and speed |
| bzip2 | Splittable, but slow |
Columnar formats compress inside the file, so each part can still be read in parallel. A large gzip CSV is a classic bad layout, because one worker has to read the whole file.
File size and partitioning
Too many small files slow every engine, because each file costs a request and some setup time. Too few huge files limit parallelism. Aim for a moderate number of reasonably large files, and compact small ones in a Glue or EMR job.
Partitioning puts files under key prefixes such as year=2026/month=10/. A query that filters on those columns reads only the matching prefixes, which is called partition pruning. Choose partition columns that queries filter on often and that do not produce thousands of tiny partitions.
Converting formats on AWS
Several services can convert formats without custom infrastructure.
- AWS Glue ETL (extract, transform, load) jobs read many formats and write Parquet or ORC.
- Athena
CREATE TABLE AS SELECT(CTAS) can write a new table in Parquet with partitions. - Amazon Data Firehose converts incoming JSON to Parquet or ORC.
- Redshift
UNLOADwrites query results to S3 in Parquet.
CREATE TABLE sales_parquet
WITH (format = 'PARQUET', external_location = 's3://my-bucket/curated/sales/',
partitioned_by = ARRAY['sale_date'])
AS SELECT order_id, amount, sale_date FROM sales_csv;
The partition column must come last in the select list.
Reading the three Vs
High volume points to scalable storage and engines such as S3 with EMR or Glue. High velocity points to Kinesis, MSK or Firehose. High variety points to a schema on read approach, with the Data Catalog describing structure and Glue or EMR handling messy inputs.
What to remember for the exam
- Parquet and ORC are columnar and the usual choice for analytics. CSV and JSON are row based text.
- Avro stores its schema with the data and suits streaming and schema evolution.
- Columnar formats cut the data scanned, which lowers Athena cost and speeds up queries.
- A plain gzip file is not splittable, so large ones limit parallel reads.
- Many tiny files hurt performance, so compact them.
- Partition on columns that queries filter on, but avoid too many tiny partitions.
- Firehose, Glue, Athena CTAS and Redshift UNLOAD can all write Parquet.
- Volume, velocity and variety are the three Vs used to pick tools.
In an Athena cost question, the best answer usually combines Parquet, compression and partitioning, not just one of them.
Common mistakes
Choosing CSV for analytics. CSV is easy to produce but forces engines to read every column of every row.
Over partitioning. Partitioning by a high cardinality column such as user ID creates huge numbers of tiny files and slows queries.
Assuming compression always helps speed. A non splittable codec on one large file can make a job slower because it cannot run in parallel.
Mixing schemas in one prefix. Files with different columns under one table path cause errors or null columns when read.
Converting to Parquet does not remove the small file problem, so write fewer, larger files after conversion.
Check yourself
Why is Parquet cheaper to query than CSV in Athena?
It is columnar and compressed, so Athena reads only the needed columns and scans fewer bytes.
Why can a single large gzip CSV slow a Spark job?
Gzip text is not splittable, so one worker must read the whole file.
Which format stores its schema with the data and suits streaming?
Avro.
Topic 3 of 8 in Data Ingestion and Transformation
Test yourself on Data Ingestion and Transformation
The full AWS DEA-C01 question bank has 845 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.