aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorYong Tang <yong.tang.github@outlook.com>2016-04-09 13:54:30 -0700
committerYin Huai <yhuai@databricks.com>2016-04-09 13:54:30 -0700
commitcd2fed70129ba601f8c849a93eeb44a5d69c2402 (patch)
treebc96c68ad2c4615ac0de174e28e2db3cafa7bc31 /sql/hive
parentf7ec854f1b7f575c4c7437daf8e6992c684b6de2 (diff)
downloadspark-cd2fed70129ba601f8c849a93eeb44a5d69c2402.tar.gz
spark-cd2fed70129ba601f8c849a93eeb44a5d69c2402.tar.bz2
spark-cd2fed70129ba601f8c849a93eeb44a5d69c2402.zip
[SPARK-14335][SQL] Describe function command returns wrong output
## What changes were proposed in this pull request? …because some of built-in functions are not in function registry. This fix tries to fix issues in `describe function` command where some of the outputs still shows Hive's function because some built-in functions are not in FunctionRegistry. The following built-in functions have been added to FunctionRegistry: ``` - ! * / & % ^ + < <= <=> = == > >= | ~ and in like not or rlike when ``` The following listed functions are not added, but hard coded in `commands.scala` (hvanhovell): ``` != <> between case ``` Below are the existing result of the above functions that have not been added: ``` spark-sql> describe function `!=`; Function: <> Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual Usage: a <> b - Returns TRUE if a is not equal to b ``` ``` spark-sql> describe function `<>`; Function: <> Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual Usage: a <> b - Returns TRUE if a is not equal to b ``` ``` spark-sql> describe function `between`; Function: between Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFBetween Usage: between a [NOT] BETWEEN b AND c - evaluate if a is [not] in between b and c ``` ``` spark-sql> describe function `case`; Function: case Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFCase Usage: CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END - When a = b, returns c; when a = d, return e; else return f ``` ## How was this patch tested? Existing tests passed. Additional test cases added. Author: Yong Tang <yong.tang.github@outlook.com> Closes #12128 from yongtang/SPARK-14335.
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala30
1 files changed, 23 insertions, 7 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 14a1d4cd30..d7ec85c15d 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
@@ -203,8 +203,7 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
checkAnswer(sql("SHOW functions abc.abs"), Row("abs"))
checkAnswer(sql("SHOW functions `abc`.`abs`"), Row("abs"))
checkAnswer(sql("SHOW functions `abc`.`abs`"), Row("abs"))
- // TODO: Re-enable this test after we fix SPARK-14335.
- // checkAnswer(sql("SHOW functions `~`"), Row("~"))
+ checkAnswer(sql("SHOW functions `~`"), Row("~"))
checkAnswer(sql("SHOW functions `a function doens't exist`"), Nil)
checkAnswer(sql("SHOW functions `weekofyea*`"), Row("weekofyear"))
// this probably will failed if we add more function with `sha` prefixing.
@@ -236,11 +235,28 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
checkExistence(sql("describe functioN abcadf"), true,
"Function: abcadf not found.")
- // TODO: Re-enable this test after we fix SPARK-14335.
- // checkExistence(sql("describe functioN `~`"), true,
- // "Function: ~",
- // "Class: org.apache.hadoop.hive.ql.udf.UDFOPBitNot",
- // "Usage: ~ n - Bitwise not")
+ checkExistence(sql("describe functioN `~`"), true,
+ "Function: ~",
+ "Class: org.apache.spark.sql.catalyst.expressions.BitwiseNot",
+ "Usage: To be added.")
+
+ // Hard coded describe functions
+ checkExistence(sql("describe function `<>`"), true,
+ "Function: <>",
+ "Usage: a <> b - Returns TRUE if a is not equal to b")
+
+ checkExistence(sql("describe function `!=`"), true,
+ "Function: !=",
+ "Usage: a != b - Returns TRUE if a is not equal to b")
+
+ checkExistence(sql("describe function `between`"), true,
+ "Function: between",
+ "Usage: a [NOT] BETWEEN b AND c - evaluate if a is [not] in between b and c")
+
+ checkExistence(sql("describe function `case`"), true,
+ "Function: case",
+ "Usage: CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END - " +
+ "When a = b, returns c; when a = d, return e; else return f")
}
test("SPARK-5371: union with null and sum") {