Skip to content
Snippets Groups Projects
Commit 7945f9f6 authored by Reynold Xin's avatar Reynold Xin Committed by Davies Liu
Browse files

[SPARK-14757] [SQL] Fix nullability bug in EqualNullSafe codegen

## What changes were proposed in this pull request?
This patch fixes a null handling bug in EqualNullSafe's code generation.

## How was this patch tested?
Updated unit test so they would fail without the fix.

Closes #12628.

Author: Reynold Xin <rxin@databricks.com>
Author: Arash Nabili <arash@levyx.com>

Closes #12799 from rxin/equalnullsafe.
parent 90fa2c6e
No related branches found
No related tags found
No related merge requests found
......@@ -467,7 +467,7 @@ case class EqualNullSafe(left: Expression, right: Expression) extends BinaryComp
val equalCode = ctx.genEqual(left.dataType, eval1.value, eval2.value)
ev.copy(code = eval1.code + eval2.code + s"""
boolean ${ev.value} = (${eval1.isNull} && ${eval2.isNull}) ||
(!${eval1.isNull} && $equalCode);""", isNull = "false")
(!${eval1.isNull} && !${eval2.isNull} && $equalCode);""", isNull = "false")
}
}
......
......@@ -273,7 +273,8 @@ class PredicateSuite extends SparkFunSuite with ExpressionEvalHelper {
}
test("BinaryComparison: null test") {
val normalInt = Literal(1)
// Use -1 (default value for codegen) which can trigger some weird bugs, e.g. SPARK-14757
val normalInt = Literal(-1)
val nullInt = Literal.create(null, IntegerType)
def nullTest(op: (Expression, Expression) => Expression): Unit = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment