access_time 3 years ago languageEnglish

Write and read parquet files in Scala / Spark

visibility 752 comment 0

Parquet is columnar store format published by Apache. It's commonly used in Hadoop ecosystem. There are many programming language APIs that have been implemented to support writing and reading parquet files. 

You can easily use Spark to read or write Parquet files. 

Code snippet

import org.apache.spark.sql.SparkSession

val appName = "Scala Parquet Example"
val master = "local"

/*Create Spark session with Hive supported.*/
val spark = SparkSession.builder.appName(appName).master(master).getOrCreate()
val df ="csv").option("header", "true").load("Sales.csv")
/*Write parquet file*/
val df2 ="Sales.parquet")
info Last modified by Raymond 3 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn.

Want to contribute on Kontext to help others?

Learn more

More from Kontext

PySpark: Read File in Google Cloud Storage
visibility 628
thumb_up 0
access_time 3 months ago
visibility 72
thumb_up 0
access_time 4 months ago
visibility 5887
thumb_up 0
access_time 11 months ago