Value join is not a member of Iterator error while doing a join


Hi Team,
I am trying to execute below code.

val orderTuple = => (l.split(",")(0).toInt, l.split(",")(2)))
val orderItemsTuple = => (l.split(",")(1).toInt, l.split(",")(4)))
val orderJoinTuple = {

It is giving me this error
Error:(20, 18) value join is not a member of Iterator[(Int, String)]

Thanks of the help in advance!

Learn Spark 1.6.x or Spark 2.x on our state of the art big data labs

  • Click here for access to state of the art 13 node Hadoop and Spark Cluster


join() operation is only available on PairedRDD. Both the RDDs should be in the form of a Key-Value pair. Try below sample code to join two RDDs

val orders = sc.textFile("/public/retail_db/orders")
val orderItems = sc.textFile("/public/retail_db/order_items")
val ordersMap = => {
  (order.split(",")(0).toInt, order.split(",")(1).substring(0, 10))
val orderItemsMap = => {
  val oi = orderItem.split(",")
  (oi(1).toInt, oi(4).toFloat)
val ordersJoin = ordersMap.join(orderItemsMap)