aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index faa7357b90..eb7a7750af 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -267,4 +267,19 @@ class SQLQuerySuite extends QueryTest {
sql("DROP TABLE nullValuesInInnerComplexTypes")
dropTempTable("testTable")
}
+
+ test("SPARK-4296 Grouping field with Hive UDF as sub expression") {
+ val rdd = sparkContext.makeRDD( """{"a": "str", "b":"1", "c":"1970-01-01 00:00:00"}""" :: Nil)
+ jsonRDD(rdd).registerTempTable("data")
+ checkAnswer(
+ sql("SELECT concat(a, '-', b), year(c) FROM data GROUP BY concat(a, '-', b), year(c)"),
+ Row("str-1", 1970))
+
+ dropTempTable("data")
+
+ jsonRDD(rdd).registerTempTable("data")
+ checkAnswer(sql("SELECT year(c) + 1 FROM data GROUP BY year(c) + 1"), Row(1971))
+
+ dropTempTable("data")
+ }
}