Uh oh!
There was an error while loading. Please reload this page.
[SPARK-29379][SQL]SHOW FUNCTIONS show '!=', '<>' , 'between', 'case' - #26053
[SPARK-29379][SQL]SHOW FUNCTIONS show '!=', '<>' , 'between', 'case'#26053AngersZhuuuu wants to merge 14 commits into
Conversation
HyukjinKwon
commented
Oct 8, 2019
Actually there are multiple instances (see https://spark.apache.org/docs/latest/api/sql/index.html). Can we remove them from the function list? |
AngersZhuuuu
commented
Oct 8, 2019
Not clear what you mean. |
HyukjinKwon
commented
Oct 8, 2019
Oh do you mean =!, <>, etc. Should be a function? I think its operator, not a function, which actually should be removed from "function"s. cc @cloud-fan and @gatorsmile |
AngersZhuuuu
commented
Oct 8, 2019
then =, == , < , etc should also be operator? |
HyukjinKwon
commented
Oct 8, 2019
Not sure if Hive resuls are correct and we dont have to follow the behaviours that dont make sense. |
AngersZhuuuu
commented
Oct 8, 2019
Ok, since |
cloud-fan
commented
Oct 8, 2019
Yea we should keep them consistent. Do you know why it's inconsistent now? Is it intentional? |
AngersZhuuuu
commented
Oct 8, 2019
Since For |
| checkAnswer(sql("SHOW functions"), getFunctions("*")) | ||
| checkAnswer(sql("SHOW functions"), (getFunctions("*") ++ | ||
| Seq(Row("!="), Row("<>"), Row("between"), Row("case")))) |
There was a problem hiding this comment.
nit: shall we put this code in getFunctions?
There was a problem hiding this comment.
nit: shall we put this code in
getFunctions?
Good ideal, I will try this.
| @@ -2065,14 +2065,14 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils { | |||
| test("show functions") { | |||
| withUserDefinedFunction("add_one" -> true) { | |||
| val numFunctions = FunctionRegistry.functionSet.size.toLong | |||
There was a problem hiding this comment.
shall we update it with val numFunctions = ... + 4?
HyukjinKwon
commented
Oct 8, 2019
Keeping it consistent sounds fine for now but I think we should fix this ambiguity between functions and operators at the end; otherwise, we will keep facing an issue such as #24947 |
HyukjinKwon
commented
Oct 8, 2019
ok to test |
SparkQA
commented
Oct 8, 2019
Test build #111907 has finished for PR 26053 at commit
|
SparkQA
commented
Oct 9, 2019
Test build #111929 has started for PR 26053 at commit |
AngersZhuuuu
commented
Oct 9, 2019
Jenkins is crashed ? |
HyukjinKwon
commented
Oct 10, 2019
retest this please |
AngersZhuuuu
commented
Oct 11, 2019
Do you have some suggestion about this problem, it's a big change. |
HyukjinKwon
commented
Oct 11, 2019
Alright, let's deal with it later separately. |
AngersZhuuuu
commented
Oct 12, 2019
@HyukjinKwon can you help to trigger retest for this PR, seems jenkins is ok. |
HyukjinKwon
commented
Oct 12, 2019
retest this please |
SparkQA
commented
Oct 12, 2019
Test build #111948 has finished for PR 26053 at commit
|
wangyum
commented
Oct 15, 2019
retest this please |
SparkQA
commented
Oct 15, 2019
Test build #112099 has finished for PR 26053 at commit
|
AngersZhuuuu
commented
Oct 16, 2019
@HyukjinKwon@cloud-fan |
| // Redefine a virtual function is not allowed | ||
| if (FunctionsCommand.virtualOperators.contains(functionName.toLowerCase(Locale.ROOT))) { | ||
| throw new AnalysisException(s"It's not allowed to redefine virtual function '$functionName'") |
There was a problem hiding this comment.
what's the error message if users try to redefine =?
There was a problem hiding this comment.
what's the error message if users try to redefine
=?
can't use create function = ...., since = is a reserved key, we should use
create function `=` ....
Error message:
org.apache.hadoop.hive.ql.metadata.HiveException: InvalidObjectException(message:= is not a valid object name);
org.apache.hadoop.hive.ql.metadata.HiveException: InvalidObjectException(message:> is not a valid object name);
org.apache.hadoop.hive.ql.metadata.HiveException: InvalidObjectException(message:!= is not a valid object name);
but `case` `between` can be registered.
as @HyukjinKwon methoned, we should fix this ambiguity between functions and operators at the end.
There was a problem hiding this comment.
If we can't fix the problem completely here, let's keep it unchanged and fix them all together later.
There was a problem hiding this comment.
If we can't fix the problem completely here, let's keep it unchanged and fix them all together later.
Ok, have remove these code.
SparkQA
commented
Oct 16, 2019
Test build #112143 has finished for PR 26053 at commit
|
| val catalog = sparkSession.sessionState.catalog | ||
| if (FunctionsCommand.virtualOperators.contains(functionName.toLowerCase(Locale.ROOT))) { | ||
| throw new AnalysisException(s"Cannot drop virtual function '$functionName'") |
There was a problem hiding this comment.
ditto, we should make sure the behavior is consistent with other operators.
There was a problem hiding this comment.
ditto
OK,
drop function `!=\case\between\<>`
here it will through exception of function not found
SparkQA
commented
Oct 16, 2019
Test build #112156 has finished for PR 26053 at commit
|
| override def run(sparkSession: SparkSession): Seq[Row] = { | ||
| val catalog = sparkSession.sessionState.catalog | ||
There was a problem hiding this comment.
Have you tried drop function '='? Does Spark fail with "function not found" or "Cannot drop native function"?
There was a problem hiding this comment.
Have you tried
drop function '='? Does Spark fail with "function not found" or "Cannot drop native function"?
Function not found.
Error in query: Function 'default.=' not found in database 'default';
There was a problem hiding this comment.
OK this can be improved later. Let's leave it for now. Thanks for the investigation!
| checkKeywordsExist(sql("describe functioN abcadf"), "Function: abcadf not found.") | ||
| } | ||
| test("drop virtual functions") { |
There was a problem hiding this comment.
since the related changes are reverted, we should remove the test as well
SparkQA
commented
Oct 16, 2019
Test build #112168 has finished for PR 26053 at commit
|
SparkQA
commented
Oct 16, 2019
Test build #112174 has finished for PR 26053 at commit
|
SparkQA
commented
Oct 16, 2019
Test build #112177 has finished for PR 26053 at commit
|
| test("show functions") { | ||
| withUserDefinedFunction("add_one" -> true) { | ||
| val numFunctions = FunctionRegistry.functionSet.size.toLong | ||
| val numFunctions = FunctionRegistry.functionSet.size.toLong + 4L |
There was a problem hiding this comment.
ah missed this one. We should use FunctionsCommand.virtualOperators.length to be future-proof.
There was a problem hiding this comment.
ah missed this one. We should use
FunctionsCommand.virtualOperators.lengthto be future-proof.
Good ideal, make it more clear. Done
| sql("SELECT testUDFToListInt(s) FROM inputTable"), | ||
| Seq(Row(Seq(1, 2, 3)))) | ||
| assert(sql("show functions").count() == numFunc + 1) | ||
| assert(sql("show functions").count() == numFunc + 5) |
There was a problem hiding this comment.
ditto
Could you help to trigger retest ?
SparkQA
commented
Oct 17, 2019
Test build #112199 has finished for PR 26053 at commit
|
SparkQA
commented
Oct 17, 2019
Test build #112201 has finished for PR 26053 at commit
|
cloud-fan
commented
Oct 18, 2019
retest this please |
SparkQA
commented
Oct 18, 2019
Test build #112263 has finished for PR 26053 at commit
|
cloud-fan
commented
Oct 18, 2019
thanks, merging to master! |
What changes were proposed in this pull request?
Current Spark SQL
SHOW FUNCTIONSdon't show!=,<>,between,caseBut these expressions is truly functions. We should show it in SQL
SHOW FUNCTIONSWhy are the changes needed?
SHOW FUNCTIONS show '!=', '<>' , 'between', 'case'
Does this PR introduce any user-facing change?
SHOW FUNCTIONS show '!=', '<>' , 'between', 'case'
How was this patch tested?
UT