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

Dataframe except returns incorrect results when combined with coalesce

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 1.6.1, 1.6.2
    • 1.6.3, 2.0.1, 2.1.0
    • SQL

    Description

      We were getting incorrect results from the DataFrame except method - all rows were being returned instead of the ones that intersected. Calling subtract on the underlying RDD returned the correct result.

      We tracked it down to the use of coalesce - the following is the simplest example case we created that reproduces the issue:

      val schema = new StructType().add("test", types.IntegerType )
      val t1 = sql.createDataFrame(sql.sparkContext.parallelize(1 to 100).map(i=> Row(i)), schema)
      val t2 = sql.createDataFrame(sql.sparkContext.parallelize(5 to 10).map(i=> Row(i)), schema)
      val t3 = t1.join(t2, t1.col("test").equalTo(t2.col("test")), "leftsemi")
      println("Count using normal except = " + t1.except(t3).count())
      println("Count using coalesce = " + t1.coalesce(8).except(t3.coalesce(8)).count())
      

      We should get the same result from both uses of except, but the one using coalesce returns 100 instead of 94.

      Attachments

        Activity

          People

            joshrosen Josh Rosen
            gedwards Graeme Edwards
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: