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

CoalesceExec can execute child plan twice

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete CommentsDelete
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.3.0, 2.3.4, 2.4.0, 2.4.8, 3.0.2, 3.1.2, 3.2.0
    • 3.2.0, 3.1.3, 3.0.4
    • SQL
    • None

    Description

      CoalesceExec calls `child.execute()` in the if condition and throws away the results, then calls `child.execute()` again in the else condition. This could cause a section of the plan to be executed twice.

      protected override def doExecute(): RDD[InternalRow] = {
        if (numPartitions == 1 && child.execute().getNumPartitions < 1) {
          // Make sure we don't output an RDD with 0 partitions, when claiming that we have a
          // `SinglePartition`.
          new CoalesceExec.EmptyRDDWithPartitions(sparkContext, numPartitions)
        } else {
          child.execute().coalesce(numPartitions, shuffle = false)
        }
      } 

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            andygrove Andy Grove Assign to me
            andygrove Andy Grove
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment