aboutsummaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorDaoyuan Wang <daoyuan.wang@intel.com>2015-11-02 23:07:30 +0800
committerCheng Lian <lian@databricks.com>2015-11-02 23:07:30 +0800
commit74ba95228d71a6dc4e95fef19f41dabe7c363d9e (patch)
tree5cd565dd8442bef5e387e0584a7bcb31fd9423bf /sql
parent767522dc4e66dd26773d41d1576945187180d2b9 (diff)
downloadspark-74ba95228d71a6dc4e95fef19f41dabe7c363d9e.tar.gz
spark-74ba95228d71a6dc4e95fef19f41dabe7c363d9e.tar.bz2
spark-74ba95228d71a6dc4e95fef19f41dabe7c363d9e.zip
[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.wang@intel.com> Closes #9277 from adrian-wang/functionreg.
Diffstat (limited to 'sql')
-rw-r--r--sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala6
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala10
2 files changed, 15 insertions, 1 deletions
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 2ccad474b4..0b5e863506 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))
}
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 b52f7d4b57..e597d6865f 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")