Hello! Welcome back to our journey through Apache Spark.
In our last lesson, we tackled how to join large datasets, focusing on the performance-critical difference between a costly shuffle join and an efficient broadcast join. We concluded that performance isn't just about the operations you run, but also about how the underlying data is organized.
Today, we'll explore that idea further by focusing on a foundational concept in modern data architecture: columnar file formats. Your learning outcome for this lesson is to explain the advantages of formats like Apache Parquet and ORC for achieving efficient I/O (Input/Output) in Spark. For a data architect, choosing the right file format is one of the most impactful decisions you can make for optimizing both performance and cost.
The Problem with Row-Based Formats in Analytics
You're likely familiar with formats like CSV or JSON. These are row-based (or row-oriented) formats. Imagine a spreadsheet: the data is stored one full row at a time.
product_id, customer_id, sale_date, amount, country101, 554, 2024-10-26, 99.99, "USA"102, 831, 2024-10-26, 19.50, "CAN"...
This structure is fine for many things, but it's very inefficient for analytical queries. Consider a typical analytical question: "What was the total sales amount yesterday?"
To answer this, a query engine reading a row-based file must:
- Read the entire first row (
101, 554, 2024-10-26, 99.99, "USA"). - Extract the one value it needs (
99.99). - Discard the rest of the row's data.
- Repeat for every single row in the file.
When dealing with terabytes of data and dozens of columns, the system wastes the vast majority of its I/O reading data that will immediately be thrown away. This is where columnar formats come in.
The Columnar Solution: Apache Parquet
Apache Parquet is an open-source columnar file format. Instead of storing data row by row, it stores it column by column.
product_id: [101, 102, ...]customer_id: [554, 831, ...]sale_date: ["2024-10-26", "2024-10-26", ...]amount: [99.99, 19.50, ...]country: ["USA", "CAN", ...]
This simple change in layout has profound implications for performance.
To start, let's get a formal definition of Parquet and its core characteristics from Databricks, a key player in the Spark ecosystem.
Apache Parquet: Efficient Data Storage
This article from Databricks provides a concise introduction to Apache Parquet.
Please read the sections "What is Parquet?" and "Characteristics of Parquet". Focus on understanding that it's a free, open-source, column-based format designed specifically for analytics.
The "Why": Key Advantages for Efficient I/O
Now that we know what Parquet is, let's explore exactly why it's so efficient for the analytical workloads common in Spark.
Apache Parquet: Efficient Data Storage
The following sections from the same Databricks article detail the specific advantages that columnar storage provides.
Read the sections "Benefits of Parquet" and "Advantages of Storing Data in a Columnar Format". As you read, pay close attention to three key concepts: (1) how only reading needed columns saves time, (2) how compression works better on columns, and (3) the idea of skipping non-relevant data.
Let's break down those three core advantages you just read about. These are essential concepts for any data architect.
1. Column Pruning (Projection Pushdown)
This is the most direct benefit. When you run a query like SELECT country, amount FROM sales, Spark can read only the data for the country and amount columns. It completely ignores the bytes on disk that store product_id, customer_id, and sale_date. This dramatically reduces I/O. In a wide table with 100+ columns, a query that only needs three of them might read 50-100x less data than it would from a CSV file.
2. Highly Efficient Compression
Data within a single column is homogeneous—it's all the same data type and often contains similar or repeating values (e.g., the country column). This structure is a perfect candidate for compression.
- Better Compression Ratios: Algorithms can use techniques like dictionary encoding (replacing "USA" with
0, "CAN" with1) and run-length encoding (storing "50 instances of0" instead of0,0,0,...). - Impact: This results in much smaller files, which not only saves on storage costs but also reduces I/O, as there is physically less data to read from disk or transfer over the network.
3. Predicate Pushdown and Data Skipping
This is a more advanced but powerful optimization. Parquet files are internally structured into "row groups" (chunks of rows). For each row group, Parquet stores metadata, including statistics like the minimum and maximum value for each column within that chunk.
When you run a filtered query, like SELECT * FROM sales WHERE country = 'USA', Spark can use this metadata. It reads the min/max values for the country column in each row group first. If a row group's metadata says its countries range from "DEU" to "FRA", Spark knows that "USA" cannot be in that chunk and skips reading it entirely.

This ability to filter data "at the source" without even reading it is called predicate pushdown, and it is another massive I/O saver.
Quantifying the Impact: Parquet vs. CSV
The benefits we've discussed have a huge real-world impact on performance and cost. As an architect, being able to quantify these benefits is key to justifying design decisions.
Apache Parquet: Efficient Data Storage
This table from the Databricks article powerfully illustrates the practical impact of converting from CSV to Parquet.
Focus on the section "Difference Between Parquet and CSV" and analyze the comparison table. Note the dramatic, order-of-magnitude savings in storage, query time, and cost.
The numbers in that table—87% less storage, 34x faster queries, 99% cost savings—are exactly the kind of metrics that demonstrate the value of sound data architecture.
How Parquet Fits into the Broader Ecosystem
While Parquet is the de facto standard in the Spark world, it's not the only specialized format. Another one you'll encounter is ORC (Optimized Row Columnar), which offers similar columnar benefits and is popular in the Hadoop/Hive ecosystem. For an architect, it's useful to know how these compare to each other and to row-based formats designed for different purposes, like Avro.
Parquet Data Format: Exploring Its Pros and Cons for 2025
This article from Edge Delta provides an excellent side-by-side comparison of Parquet against other common formats.
Please review the comparison table in the section "Parquet vs. Other Formats". Pay special attention to the "Storage Type" and "Best Use Cases" rows to understand why you might choose one over another. For instance, notice that Avro is row-based and often preferred for streaming use cases where writing entire records quickly is the priority.
The key architectural takeaway is to choose the right tool for the job:
- Columnar (Parquet, ORC): Optimized for read-heavy, analytical (OLAP) workloads where you query a subset of columns.
- Row-based (Avro, CSV, JSON): Better suited for write-heavy, transactional (OLTP) or streaming workloads where you process entire records at once.
Test your understanding!
You are designing a data pipeline that processes 1TB of user activity data daily. The raw data arrives in JSON format. An hourly analytics job needs to calculate the number of unique users from Germany.
From an I/O efficiency perspective, what is the most critical architectural recommendation you would make regarding data storage before the analytics job runs? Explain your reasoning based on the three main advantages of columnar formats.
Show answer
The critical recommendation is to convert the raw JSON data into Parquet format and store it in the data lake before running the analytics job.
Reasoning:
- Column Pruning: The analytics job only needs the
user_idandcountrycolumns. By storing the data in Parquet, Spark can read only these two columns, drastically reducing the amount of data read from disk compared to reading the full 1TB of JSON data. - Predicate Pushdown: The filter
WHERE country = 'Germany'allows Spark to use Parquet's internal metadata. It can check the min/max values for thecountrycolumn in each data block and skip any blocks that do not contain "Germany", further reducing I/O. - Efficient Compression: The
countrycolumn, with its many repeating values, will compress extremely well in Parquet. This reduces the total storage footprint and the amount of data that needs to be read from disk, leading to faster queries and lower storage costs.
Conclusion
Today, you've learned about one of the most fundamental optimizations in modern data systems. By understanding how data is physically laid out on disk, you can design systems that are dramatically faster and more cost-effective.
Key Takeaways:
- Row-based formats (CSV, JSON) are inefficient for analytics because they force engines to read entire rows even when only a few columns are needed.
- Columnar formats (Parquet, ORC) store data column by column, enabling massive I/O savings.
- The three key advantages are:
- Column Pruning: Read only the columns you need.
- Efficient Compression: Reduce file size by compressing homogeneous data.
- Predicate Pushdown: Skip reading entire blocks of data that don't match your query's filter.
- Choosing a columnar format like Parquet for your analytical data is a foundational architectural best practice.
In our next lesson, we will put this theory into practice. You will learn how to read from and write to Parquet files using Spark, cementing your understanding of how to leverage this powerful format in your data pipelines.