Skip to content

Commit be56898

Browse files
committed
Print an warning mesages in '<=>'
1 parent c228100 commit be56898

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/Column.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,15 @@ class Column(val expr: Expression) extends Logging {
464464
* @group expr_ops
465465
* @since 1.3.0
466466
*/
467-
def <=> (other: Any): Column = withExpr { EqualNullSafe(expr, lit(other).expr) }
467+
def <=> (other: Any): Column = withExpr {
468+
val right = lit(other).expr
469+
if (this.expr == right) {
470+
logWarning(
471+
s"Constructing trivially true equals predicate, '${this.expr} = $right'. " +
472+
"Perhaps you need to use aliases.")
473+
}
474+
EqualNullSafe(expr, right)
475+
}
468476

469477
/**
470478
* Equality test that is safe for null values.

0 commit comments

Comments
 (0)