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

When using UnsafeRows, SortMergeJoin may return wrong results

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.5.1, 1.6.0
    • Component/s: SQL
    • Labels:
      None

      Description

      val df1 = (1 to 10).map(i => (s"str_$i", i)).toDF("i", "j")
      val df2 =
        df1
        .join(df1.select(df1("i")), "i")
        .select(df1("i"), df1("j"))
      
      val df3 = df2.withColumnRenamed("i", "i1").withColumnRenamed("j", "j1")
      val df4 =
        df2
        .join(df3, df2("i") === df3("i1"))
        .withColumn("diff", $"j" - $"j1")
      
      df4.show(100, false)
      
      +------+---+------+---+----+
      |i     |j  |i1    |j1 |diff|
      +------+---+------+---+----+
      |str_2 |2  |str_2 |2  |0   |
      |str_7 |7  |str_2 |2  |5   |
      |str_10|10 |str_10|10 |0   |
      |str_3 |3  |str_3 |3  |0   |
      |str_8 |8  |str_3 |3  |5   |
      |str_4 |4  |str_4 |4  |0   |
      |str_9 |9  |str_4 |4  |5   |
      |str_5 |5  |str_5 |5  |0   |
      |str_1 |1  |str_1 |1  |0   |
      |str_6 |6  |str_1 |1  |5   |
      +------+---+------+---+----+
      
      

        Attachments

          Activity

            People

            • Assignee:
              yhuai Yin Huai
              Reporter:
              yhuai Yin Huai
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: