Javatpoint Logo
Javatpoint Logo

Spark cogroup Function

In Spark, the cogroup function performs on different datasets, let's say, (K, V) and (K, W) and returns a dataset of (K, (Iterable, Iterable)) tuples. This operation is also known as groupWith.

Example of cogroup Function

In this example, we perform the groupWith operation.

  • To open the Spark in Scala mode, follow the below command.
Spark cogroup Function
  • Create an RDD using the parallelized collection.

Now, we can read the generated result by using the following command.

Spark cogroup Function
  • Create another RDD using the parallelized collection.

Now, we can read the generated result by using the following command.

Spark cogroup Function
  • Apply cogroup() function to group the values.
  • Now, we can read the generated result by using the following command.
Spark cogroup Function

Here, we got the desired output.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA