92
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.
- Create an RDD using the parallelized collection.
- Now, we can read the generated result by using the following command.
- Apply first() function to retrieve the first element of the dataset.
Here, we got the desired output.
Next TopicSpark Take Function