You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2017/07/03 17:14:08 UTC
spark git commit: [SPARK-20073][SQL] Prints an explicit warning
message in case of NULL-safe equals
Repository: spark
Updated Branches:
refs/heads/master 17bdc36ef -> 363bfe30b
[SPARK-20073][SQL] Prints an explicit warning message in case of NULL-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 <ya...@apache.org>
Closes #18436 from maropu/SPARK-20073.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/363bfe30
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/363bfe30
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/363bfe30
Branch: refs/heads/master
Commit: 363bfe30ba44852a8fac946a37032f76480f6f1b
Parents: 17bdc36
Author: Takeshi Yamamuro <ya...@apache.org>
Authored: Mon Jul 3 10:14:03 2017 -0700
Committer: gatorsmile <ga...@gmail.com>
Committed: Mon Jul 3 10:14:03 2017 -0700
----------------------------------------------------------------------
sql/core/src/main/scala/org/apache/spark/sql/Column.scala | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/363bfe30/sql/core/src/main/scala/org/apache/spark/sql/Column.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala
index 7e1f1d8..bd1669b 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala
@@ -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.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org