Repository: spark
Updated Branches:
  refs/heads/master 767522dc4 -> 74ba95228


[SPARK-11311][SQL] spark cannot describe temporary functions

When describe temporary function, spark would return 'Unable to find function', 
this is not right.

Author: Daoyuan Wang <daoyuan.w...@intel.com>

Closes #9277 from adrian-wang/functionreg.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/74ba9522
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/74ba9522
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/74ba9522

Branch: refs/heads/master
Commit: 74ba95228d71a6dc4e95fef19f41dabe7c363d9e
Parents: 767522d
Author: Daoyuan Wang <daoyuan.w...@intel.com>
Authored: Mon Nov 2 23:07:30 2015 +0800
Committer: Cheng Lian <l...@databricks.com>
Committed: Mon Nov 2 23:07:30 2015 +0800

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/sql/hive/hiveUDFs.scala   |  6 +++++-
 .../apache/spark/sql/hive/execution/HiveQuerySuite.scala  | 10 ++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/74ba9522/sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala
----------------------------------------------------------------------
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 2ccad47..0b5e863 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
@@ -119,7 +119,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))
   }

http://git-wip-us.apache.org/repos/asf/spark/blob/74ba9522/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
----------------------------------------------------------------------
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 b52f7d4..e597d68 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
@@ -953,6 +953,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)
+    assert(sql("DESCRIBE FUNCTION udtf_count2").count > 1)
+    sql("DROP TEMPORARY FUNCTION udtf_count2")
+  }
+
   test("ADD FILE command") {
     val testFile = TestHive.getHiveFile("data/files/v1.txt").getCanonicalFile
     sql(s"ADD FILE $testFile")


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to