scala

22 items tagged with "scala"

22 Articles

Articles

Find Number of Rows of Hive Table via Scala

To find the number of rows/records in a Hive table, we can use Spark SQL count aggregation function: Hive SQL - Aggregate Functions Overview with Examples. This code snippet provide example of Scala code to implement the same. spark-shell is used directly for simplicity. The code snippet can also run Jupyter Notebooks or Zeppelin with Spark kernel. Alternatively, it can be compiled to jar file and then submit as job via spark-submit. !2022082315649-image.png

2022-08-23
Code Snippets & Tips

Spark submit --num-executors --executor-cores --executor-memory

2022-03-29
Spark & PySpark

Spark Dataset and DataFrame

2021-10-13
Spark & PySpark

Spark Scala: Load Data from MySQL

2021-01-24
Spark & PySpark

Spark Scala: Load Data from SQL Server

2020-12-18
Spark & PySpark

Spark Scala: Read XML File as DataFrame

2020-12-16
Spark & PySpark

Scala: Read JSON file as Spark DataFrame

2020-12-16
Code Snippets & Tips

Scala: Read CSV File as Spark DataFrame

2020-12-16
Spark & PySpark

Scala: Parse JSON String as Spark DataFrame

2020-12-16
Spark & PySpark

Scala: Change Column Type in Spark Data Frame

2020-12-14
Spark & PySpark

Scala: Filter Spark DataFrame Columns with None or Null Values

This article shows you how to filter NULL/None values from a Spark data frame using Scala. Function DataFrame.filter or DataFrame.where can be used to filter out null values.

2020-12-14
Spark & PySpark

Scala - Add Constant Column to Spark Data Frame

2020-12-14
Spark & PySpark

Scala: Remove Columns from Spark Data Frame

2020-12-13
Spark & PySpark

Scala: Change Data Frame Column Names in Spark

2020-12-13
Spark & PySpark

Scala: Convert List to Spark Data Frame

2020-12-13
Spark & PySpark

Write and read parquet files in Scala / Spark

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.

2019-11-18
Code Snippets & Tips

Convert string to date in Scala / Spark

This code snippet shows how to convert string to date.

2019-11-18
Code Snippets & Tips

Read JSON file as Spark DataFrame in Scala / Spark

Spark has easy fluent APIs that can be used to read data from JSON file as DataFrame object.

2019-11-18
Code Snippets & Tips

Convert List to Spark Data Frame in Scala / Spark

In Spark, SparkContext.parallelize function can be used to convert list of objects to RDD and then RDD can be converted to DataFrame object through SparkSession.

2019-11-18
Code Snippets & Tips

Write and Read Parquet Files in HDFS through Spark/Scala

2018-03-17
Spark & PySpark

Write and Read Parquet Files in Spark/Scala

2018-03-17
Spark & PySpark

Convert String to Date in Spark (Scala)

2018-03-04
Spark & PySpark