diff options
author | Volodymyr Lyubinets <vlyubin@gmail.com> | 2015-03-12 00:55:26 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-03-12 00:55:26 -0700 |
commit | 25b71d8c15572f0f2b951c827c169f8c65f726ad (patch) | |
tree | e11b8b580cfaadf388813b6bd205c893c5853d0c | |
parent | e921a665c56950c03155f4b47500627265a4ba8e (diff) | |
download | spark-25b71d8c15572f0f2b951c827c169f8c65f726ad.tar.gz spark-25b71d8c15572f0f2b951c827c169f8c65f726ad.tar.bz2 spark-25b71d8c15572f0f2b951c827c169f8c65f726ad.zip |
[SPARK-6296] [SQL] Added equals to Column
Author: Volodymyr Lyubinets <vlyubin@gmail.com>
Closes #4988 from vlyubin/columncomp and squashes the following commits:
92d7c8f [Volodymyr Lyubinets] Added equals to Column
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/Column.scala | 7 | ||||
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala | 5 |
2 files changed, 12 insertions, 0 deletions
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 a2cc9a9b93..908c78a4d3 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 @@ -59,6 +59,13 @@ class Column(protected[sql] val expr: Expression) { override def toString: String = expr.prettyString + override def equals(that: Any) = that match { + case that: Column => that.expr.equals(this.expr) + case _ => false + } + + override def hashCode: Int = this.expr.hashCode + /** * Unary minus, i.e. negate the expression. * {{{ diff --git a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala index 37c02aaa54..3036fbc05d 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala @@ -313,4 +313,9 @@ class ColumnExpressionSuite extends QueryTest { test("lift alias out of cast") { assert(col("1234").as("name").cast("int").expr === col("1234").cast("int").as("name").expr) } + + test("columns can be compared") { + assert('key.desc == 'key.desc) + assert('key.desc != 'key.asc) + } } |