Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-28854

Zipping iterators in mapPartitions will fail

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Invalid
    • Affects Version/s: 2.4.3
    • Fix Version/s: None
    • Component/s: Spark Core
    • Labels:
      None

      Description

      scala> sc.parallelize(Seq(1, 2, 3)).mapPartitions(xs => xs.map(2*).zip(xs)).collect.foreach(println)
      
      ...
      
      java.util.NoSuchElementException: next on empty iterator
      

       

       

      Workaround - implement zip with mapping to tuple:

      scala> sc.parallelize(Seq(1, 2, 3)).mapPartitions(xs => xs.map(x => (x * 2, x))).collect.foreach(println)
      (2,1)
      (4,2)
      (6,3)
      

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              yangzai Hao Yang Ang
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: