aboutsummaryrefslogtreecommitdiff
path: root/sql/hive-thriftserver/src
diff options
context:
space:
mode:
authorCheng Lian <lian@databricks.com>2015-11-12 12:17:51 -0800
committerMichael Armbrust <michael@databricks.com>2015-11-12 12:17:51 -0800
commit4fe99c72c60646b1372bb2c089c6fc7c4fa11644 (patch)
treea3101600fe5ba7732c90bbd12c826d8bd12aea9a /sql/hive-thriftserver/src
parentdf0e318152165c8e50793aff13aaca5d2d9b8b9d (diff)
downloadspark-4fe99c72c60646b1372bb2c089c6fc7c4fa11644.tar.gz
spark-4fe99c72c60646b1372bb2c089c6fc7c4fa11644.tar.bz2
spark-4fe99c72c60646b1372bb2c089c6fc7c4fa11644.zip
[SPARK-11191][SQL] Looks up temporary function using execution Hive client
When looking up Hive temporary functions, we should always use the `SessionState` within the execution Hive client, since temporary functions are registered there. Author: Cheng Lian <lian@databricks.com> Closes #9664 from liancheng/spark-11191.fix-temp-function.
Diffstat (limited to 'sql/hive-thriftserver/src')
-rw-r--r--sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala45
1 files changed, 45 insertions, 0 deletions
diff --git a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
index 5903b9e71c..eb1895f263 100644
--- a/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
+++ b/sql/hive-thriftserver/src/test/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2Suites.scala
@@ -463,6 +463,51 @@ class HiveThriftBinaryServerSuite extends HiveThriftJdbcTest {
assert(conf.get("spark.sql.hive.version") === Some("1.2.1"))
}
}
+
+ test("SPARK-11595 ADD JAR with input path having URL scheme") {
+ withJdbcStatement { statement =>
+ val jarPath = "../hive/src/test/resources/TestUDTF.jar"
+ val jarURL = s"file://${System.getProperty("user.dir")}/$jarPath"
+
+ Seq(
+ s"ADD JAR $jarURL",
+ s"""CREATE TEMPORARY FUNCTION udtf_count2
+ |AS 'org.apache.spark.sql.hive.execution.GenericUDTFCount2'
+ """.stripMargin
+ ).foreach(statement.execute)
+
+ val rs1 = statement.executeQuery("DESCRIBE FUNCTION udtf_count2")
+
+ assert(rs1.next())
+ assert(rs1.getString(1) === "Function: udtf_count2")
+
+ assert(rs1.next())
+ assertResult("Class: org.apache.spark.sql.hive.execution.GenericUDTFCount2") {
+ rs1.getString(1)
+ }
+
+ assert(rs1.next())
+ assert(rs1.getString(1) === "Usage: To be added.")
+
+ val dataPath = "../hive/src/test/resources/data/files/kv1.txt"
+
+ Seq(
+ s"CREATE TABLE test_udtf(key INT, value STRING)",
+ s"LOAD DATA LOCAL INPATH '$dataPath' OVERWRITE INTO TABLE test_udtf"
+ ).foreach(statement.execute)
+
+ val rs2 = statement.executeQuery(
+ "SELECT key, cc FROM test_udtf LATERAL VIEW udtf_count2(value) dd AS cc")
+
+ assert(rs2.next())
+ assert(rs2.getInt(1) === 97)
+ assert(rs2.getInt(2) === 500)
+
+ assert(rs2.next())
+ assert(rs2.getInt(1) === 97)
+ assert(rs2.getInt(2) === 500)
+ }
+ }
}
class HiveThriftHttpServerSuite extends HiveThriftJdbcTest {