aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src/test
diff options
context:
space:
mode:
authorTakeshi Yamamuro <yamamuro@apache.org>2017-03-05 03:53:19 -0800
committerHerman van Hovell <hvanhovell@databricks.com>2017-03-05 03:53:19 -0800
commit14bb398fae974137c3e38162cefc088e12838258 (patch)
treecb83b0f4b81c86a8a22237d818170247bbc9e825 /sql/core/src/test
parentf48461ab2bdb91cd00efa5a5ec4b0b2bc361e7a2 (diff)
downloadspark-14bb398fae974137c3e38162cefc088e12838258.tar.gz
spark-14bb398fae974137c3e38162cefc088e12838258.tar.bz2
spark-14bb398fae974137c3e38162cefc088e12838258.zip
[SPARK-19254][SQL] Support Seq, Map, and Struct in functions.lit
## What changes were proposed in this pull request? This pr is to support Seq, Map, and Struct in functions.lit; it adds a new IF named `lit2` with `TypeTag` for avoiding type erasure. ## How was this patch tested? Added tests in `LiteralExpressionSuite` Author: Takeshi Yamamuro <yamamuro@apache.org> Author: Takeshi YAMAMURO <linguin.m.s@gmail.com> Closes #16610 from maropu/SPARK-19254.
Diffstat (limited to 'sql/core/src/test')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala14
1 files changed, 14 insertions, 0 deletions
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 ee280a313c..b0f398dab7 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
@@ -712,4 +712,18 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext {
testData2.select($"a".bitwiseXOR($"b").bitwiseXOR(39)),
testData2.collect().toSeq.map(r => Row(r.getInt(0) ^ r.getInt(1) ^ 39)))
}
+
+ test("typedLit") {
+ val df = Seq(Tuple1(0)).toDF("a")
+ // Only check the types `lit` cannot handle
+ checkAnswer(
+ df.select(typedLit(Seq(1, 2, 3))),
+ Row(Seq(1, 2, 3)) :: Nil)
+ checkAnswer(
+ df.select(typedLit(Map("a" -> 1, "b" -> 2))),
+ Row(Map("a" -> 1, "b" -> 2)) :: Nil)
+ checkAnswer(
+ df.select(typedLit(("a", 2, 1.0))),
+ Row(Row("a", 2, 1.0)) :: Nil)
+ }
}