Reading Parquet and ORC data in Spark

Parquet and ORC are columnar data formats which provided multiple storage optimizations and processing speed especially for data processing. Spark’s default file format is Parquet. Spark also works well with ORC file formats. In this blog, we are going to learn about reading parquet and ORC data in Spark.

Reading Parquet data

Parquet enforces its own schema while storing data. So reading parquet data in Spark is very easy, and we do not have to provide a lot of options to get the desired result.

Apart from this, we have slight variations to read parquet data as well.

Specifying Compression Type

We can also specify compression type used for our data. By default, it is “gzip”. Below are other acceptable values.

  • uncompressed
  • bzip2
  • deflate
  • gzip
  • lz4
  • snappy

Reading ORC files in Spark

Though Spark is more optimized to work with parquet file format, it also understands ORC file format well. ORC also stores schema information with a file so reading ORC data is as easy as reading parquet in Spark.

Conclusion

In this blog, we have learned to work with Parquet and ORC file formats when using Spark. You can find code written in this blog at git as well. I hope you have found this useful.

Similar Posts

Leave a Reply

Your email address will not be published.