Javatpoint Logo
Javatpoint Logo

Spark First Function

In Spark, the First function always returns the first element of the dataset. It is similar to take(1).

Example of First function

In this example, we retrieve the first element of the dataset.

  • To open the Spark in Scala mode, follow the below command.
Spark First Function
  • Create an RDD using the parallelized collection.
  • Now, we can read the generated result by using the following command.
Spark First Function
  • Apply first() function to retrieve the first element of the dataset.
Spark First Function

Here, we got the desired output.






Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA