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

StopIteration in pyspark mapper gives partial results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.3.0
    • Fix Version/s: None
    • Component/s: PySpark
    • Labels:
      None

      Description

      Consider the following code

      def mapper(xx):
           if xx % 2 == 0:
               raise StopIteration()
           else:
               return xx
      sc.parallelize(range(100)).map(mapper).collect()
      

      The result I get is [57, 71, 85]

      I think it happens because map is implemented in terms of mapPartitionsWithIndex using a custom iterator, so the StopIteration raised by the mapper is handled by that iterator. I think this should be raised to the user instead.

      I think I can take care of this, if I am allowed to (first time I contribute, not sure how it works)

      NB: this may be the underlying cause of https://issues.apache.org/jira/browse/SPARK-23754

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                edorigatti Emilio Dorigatti
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: