From e1c0a98ee0aa0d26b9cda14dc48502162cf2091b Mon Sep 17 00:00:00 2001 From: Daoyuan Wang Date: Sun, 25 Oct 2015 23:57:19 -0700 Subject: [PATCH 1/2] fix temporary function description --- .../scala/org/apache/spark/sql/hive/hiveUDFs.scala | 6 +++++- .../spark/sql/hive/execution/HiveQuerySuite.scala | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala index 18bbdb9908142..00ef48d0270ee 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala @@ -115,7 +115,11 @@ private[hive] class HiveFunctionRegistry(underlying: analysis.FunctionRegistry) annotation.value(), annotation.extended())) } else { - None + Some(new ExpressionInfo( + info.getFunctionClass.getCanonicalName, + name, + null, + null)) } }.getOrElse(None)) } diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala index 2878500453141..17f9a19e7d07d 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala @@ -899,6 +899,16 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter { sql("DROP TABLE t1") } + test("CREATE TEMPORARY FUNCTION") { + val funcJar = TestHive.getHiveFile("TestUDTF.jar").getCanonicalPath + sql(s"ADD JAR $funcJar") + sql( + """CREATE TEMPORARY FUNCTION udtf_count2 AS + | 'org.apache.spark.sql.hive.execution.GenericUDTFCount2'""".stripMargin) + sql("DESCRIBE FUNCTION udtf_count2") + sql("DROP TEMPORARY FUNCTION udtf_count2") + } + test("ADD FILE command") { val testFile = TestHive.getHiveFile("data/files/v1.txt").getCanonicalFile sql(s"ADD FILE $testFile") From 50bdef7b41a7e7d1beff4debc27f6b9eea2aafc5 Mon Sep 17 00:00:00 2001 From: Daoyuan Wang Date: Mon, 26 Oct 2015 00:01:35 -0700 Subject: [PATCH 2/2] refine test --- .../org/apache/spark/sql/hive/execution/HiveQuerySuite.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala index 17f9a19e7d07d..901b2179e0e40 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala @@ -905,7 +905,7 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter { sql( """CREATE TEMPORARY FUNCTION udtf_count2 AS | 'org.apache.spark.sql.hive.execution.GenericUDTFCount2'""".stripMargin) - sql("DESCRIBE FUNCTION udtf_count2") + assert(sql("DESCRIBE FUNCTION udtf_count2").count > 1) sql("DROP TEMPORARY FUNCTION udtf_count2") }