Skip to content

Commit

Permalink
[DataFrame][minor] support column in field accessor
Browse files Browse the repository at this point in the history
Minor improvement, now we can use `Column` as extraction expression.

Author: Wenchen Fan <[email protected]>

Closes apache#6080 from cloud-fan/tmp and squashes the following commits:

0fdefb7 [Wenchen Fan] support column in field accessor
  • Loading branch information
cloud-fan authored and nemccarthy committed Jun 19, 2015
1 parent 3f57317 commit 30a7be9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 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 @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 30a7be9

Please sign in to comment.