-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29379][SQL]SHOW FUNCTIONS show '!=', '<>' , 'between', 'case' #26053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Actually there are multiple instances (see https://spark.apache.org/docs/latest/api/sql/index.html). Can we remove them from the function list? |
Not clear what you mean. |
|
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 |
then =, == , < , etc should also be operator? |
|
Not sure if Hive resuls are correct and we dont have to follow the behaviours that dont make sense. |
Ok, since |
|
Yea we should keep them consistent. Do you know why it's inconsistent now? Is it intentional? |
Since For spark/sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala Line 116 in 9b8d63e
|
|
|
||
| checkAnswer(sql("SHOW functions"), getFunctions("*")) | ||
| checkAnswer(sql("SHOW functions"), (getFunctions("*") ++ | ||
| Seq(Row("!="), Row("<>"), Row("between"), Row("case")))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shall we put this code in getFunctions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: shall we put this code in
getFunctions?
Good ideal, I will try this.
|
|
||
| test("show functions") { | ||
| withUserDefinedFunction("add_one" -> true) { | ||
| val numFunctions = FunctionRegistry.functionSet.size.toLong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we update it with val numFunctions = ... + 4?
|
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 |
|
ok to test |
|
Test build #111907 has finished for PR 26053 at commit
|
|
Test build #111929 has started for PR 26053 at commit |
|
Jenkins is crashed ? |
|
retest this please |
Do you have some suggestion about this problem, it's a big change. |
|
Alright, let's deal with it later separately. |
|
@HyukjinKwon can you help to trigger retest for this PR, seems jenkins is ok. |
|
retest this please |
|
Test build #111948 has finished for PR 26053 at commit
|
|
retest this please |
|
Test build #112099 has finished for PR 26053 at commit
|
|
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the error message if users try to redefine =?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, we should make sure the behavior is consistent with other operators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
OK,
drop function `!=\case\between\<>`
here it will through exception of function not found
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried drop function '='? Does Spark fail with "function not found" or "Cannot drop native function"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the related changes are reverted, we should remove the test as well
|
Test build #112168 has finished for PR 26053 at commit
|
|
Test build #112174 has finished for PR 26053 at commit
|
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah missed this one. We should use FunctionsCommand.virtualOperators.length to be future-proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
Could you help to trigger retest ?
|
Test build #112199 has finished for PR 26053 at commit
|
|
Test build #112201 has finished for PR 26053 at commit
|
|
retest this please |
|
Test build #112263 has finished for PR 26053 at commit
|
|
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