How to Read and Write ORC Files in PySpark?

Spread the love

ORC Files –

ORC is a self-describing, type aware columnar file format designed for Hadoop workloads. It is optimized for large streaming reads, but with integrated support for finding required rows quickly. ORC actually has no options for reading in data because spark understands the file format quite well. An often asked question is – What is the difference between ORC and Parquet? For the most part, they are quite similar, the fundamental difference is that Parquet is further optimized for use with Spark, whereas ORC is further optimized for Hive.

Reading ORC Files –

To read a ORC file in PySpark, we have to write

from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()

df ='orc').load('../data/2010-summary.orc')

Writing ORC Files –

And to save a PySpark dataframe to a ORC file, we write


Related Posts –

  1. How to Read a CSV File into a DataFrame in PySpark ?
  2. How to Read a JSON File into a DataFrame in PySpark ?
  3. How to Read and Write Parquet Files in PySpark?

Rating: 1 out of 5.

Leave a Reply