Skip to content

Commit

Permalink
[SPARK-20073][SQL] Prints an explicit warning message in case of NULL…
Browse files Browse the repository at this point in the history
…-safe equals

## What changes were proposed in this pull request?
This pr added code to print the same warning messages with `===` cases when using NULL-safe equals (`<=>`).

## How was this patch tested?
Existing tests.

Author: Takeshi Yamamuro <yamamuro@apache.org>

Closes #18436 from maropu/SPARK-20073.
  • Loading branch information
maropu authored and gatorsmile committed Jul 3, 2017
1 parent 17bdc36 commit 363bfe3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sql/core/src/main/scala/org/apache/spark/sql/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,15 @@ class Column(val expr: Expression) extends Logging {
* @group expr_ops
* @since 1.3.0
*/
def <=> (other: Any): Column = withExpr { EqualNullSafe(expr, lit(other).expr) }
def <=> (other: Any): Column = withExpr {
val right = lit(other).expr
if (this.expr == right) {
logWarning(
s"Constructing trivially true equals predicate, '${this.expr} <=> $right'. " +
"Perhaps you need to use aliases.")
}
EqualNullSafe(expr, right)
}

/**
* Equality test that is safe for null values.
Expand Down

0 comments on commit 363bfe3

Please sign in to comment.