Javatpoint Logo
Javatpoint Logo

Spark Take Function

In Spark, the take function behaves like an array. It receives an integer value (let say, n) as a parameter and returns an array of first n elements of the dataset.

Example of Take function

In this example, we return the first n elements of an existing dataset.

  • To open the Spark in Scala mode, follow the below command.
Spark Take Function
  • Create an RDD using the parallelized collection.
  • Now, we can read the generated result by using the following command.
Spark Take Function
  • Apply take() function to return an array of elements.
Spark Take Function

Here, we got the desired output.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA