Skip to the page
Tecyfy

PySpark interview question · medium

What are the differences between Avro and ORC, and which one is preferable?

The short answerAvro is a row-based format built for writing and exchanging records one at a time, with a schema that travels with the data and strong rules for schema evolution.

The full answer

Avro is a row-based format built for writing and exchanging records one at a time, with a schema that travels with the data and strong rules for schema evolution. ORC is a columnar format built for analytical reads. Neither is better in general: Avro suits streaming, messaging and ingestion; ORC (or Parquet) suits analytics.

AvroORC
LayoutRow-basedColumnar (stripes of column data)
Best atWriting whole records quickly; reading whole recordsReading a few columns of many rows
SchemaJSON schema stored with the file; schema registries for messagesStored in the file footer
Schema evolutionRich, well-defined rules for adding, removing and renaming fields with defaultsAdding columns supported; other changes are more limited
CompressionBlock-level (Snappy, Deflate, zstd)Columnar encodings plus codecs; very compact
Data skippingNoneMin and max statistics per stripe and row group, optional Bloom filters
Typical homeKafka messages, change data capture, ingestion and landing zones, data exchangeHive-based data warehouses, analytical tables
Spark supportThe spark-avro module (built in, but deployed separately, for example with --packages); from_avro and to_avro for Kafka payloadsBuilt in, with a vectorised native reader

When Avro is preferable

  • Streaming and messaging: each Kafka message is one Avro record, validated against a schema in a schema registry.
  • Write-heavy landing of raw data, where whole records are always read back.
  • Contracts between teams or systems where schemas evolve and compatibility rules matter.

When ORC is preferable

  • Analytical queries that read a few columns and filter rows: columnar reading, compression and statistics make them far faster than Avro.
  • Existing Hive ecosystems, where ORC is the native format and supports Hive's ACID tables.

Where Parquet fits In Spark-centred and cloud lakehouse systems, Parquet is the more common columnar choice: it has the widest tool support and is the storage format under Delta Lake and Iceberg (Iceberg can also use ORC and Avro). ORC and Parquet perform similarly; ecosystem support usually decides.

A common pattern Data arrives as Avro (or JSON) from Kafka or change data capture, is landed as is, then converted into columnar tables (Parquet or ORC, usually through Delta or Iceberg) for analytics. So the honest answer is: choose by workload, and often use both.

# Kafka value in Avro → columnar table
from pyspark.sql.avro.functions import from_avro

events = (spark.readStream.format("kafka")
            .option("kafka.bootstrap.servers", "broker:9092")
            .option("subscribe", "orders")
            .load()
            .select(from_avro("value", orders_avro_schema_json).alias("o"))
            .select("o.*"))

Last updated 16 October 2026

Sources

Where each fact comes from

  1. 1Apache Avro data source guide
  2. 2ORC files
  3. 3Parquet files