diff options
author | Wenchen Fan <cloud0fan@outlook.com> | 2015-05-12 10:37:57 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2015-05-12 10:37:57 -0700 |
commit | bfcaf8adcdc20dec203e2e9d5a72b52dd6f226a9 (patch) | |
tree | f08544fe3f913be08802711a66e422f2c35097dc /sql/core | |
parent | 0595b6de8f1da04baceda082553c2aa1aa2cb006 (diff) | |
download | spark-bfcaf8adcdc20dec203e2e9d5a72b52dd6f226a9.tar.gz spark-bfcaf8adcdc20dec203e2e9d5a72b52dd6f226a9.tar.bz2 spark-bfcaf8adcdc20dec203e2e9d5a72b52dd6f226a9.zip |
[DataFrame][minor] support column in field accessor
Minor improvement, now we can use `Column` as extraction expression.
Author: Wenchen Fan <cloud0fan@outlook.com>
Closes #6080 from cloud-fan/tmp and squashes the following commits:
0fdefb7 [Wenchen Fan] support column in field accessor
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/Column.scala | 2 | ||||
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala | 1 |
2 files changed, 2 insertions, 1 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 e6e475bb82..4d50821620 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 @@ -78,7 +78,7 @@ class Column(protected[sql] val expr: Expression) extends Logging { * * @group expr_ops */ - def apply(field: Any): Column = UnresolvedExtractValue(expr, Literal(field)) + def apply(extraction: Any): Column = UnresolvedExtractValue(expr, lit(extraction).expr) /** * Unary minus, i.e. negate the expression. diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala index 2ade955864..d58438e5d1 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala @@ -456,6 +456,7 @@ class DataFrameSuite extends QueryTest { assert(complexData.filter(complexData("a")(0) === 2).count() == 1) assert(complexData.filter(complexData("m")("1") === 1).count() == 1) assert(complexData.filter(complexData("s")("key") === 1).count() == 1) + assert(complexData.filter(complexData("m")(complexData("s")("value")) === 1).count() == 1) } test("SPARK-7324 dropDuplicates") { |