> For the complete documentation index, see [llms.txt](https://george-jen.gitbook.io/data-science-and-apache-spark/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://george-jen.gitbook.io/data-science-and-apache-spark/join-otherstream-numtasks.md).

# join(otherStream, \[numTasks])

### join(otherStream, \[numTasks])

When called on two DStreams of (K, V) and (K, W) pairs, return a new DStream of (K, (V, W)) pairs with all pairs of elements for each key.

```
import org.apache.spark._
import org.apache.spark.SparkContext._
import org.apache.spark.streaming._
import org.apache.spark.streaming.StreamingContext._
import org.apache.log4j.{Level, Logger}

val conf = new SparkConf()
 .setMaster("local[2]").setAppName("NetworkWordCount")
sc.stop
val ssc = new StreamingContext(conf, Seconds(1))
import org.apache.spark.rdd.RDD
import scala.collection.mutable.Queue
val rddQueue = new Queue[RDD[(Int,Int)]]()
val inputStream = ssc.queueStream(rddQueue)
inputStream.join(inputStream)

/*
res4: org.apache.spark.streaming.dstream.DStream[(Int, (Int, Int))] = org.apache.spark.streaming.dstream.TransformedDStream@7296b9c6
*/
```
