Uh oh!
There was an error while loading. Please reload this page.
[SPARK-28143][SQL] Expressions without proper constructors should throw AnalysisException - #24947
[SPARK-28143][SQL] Expressions without proper constructors should throw AnalysisException#24947yaooqinn wants to merge 5 commits into
Conversation
yaooqinn
commented
Jun 24, 2019
cc @cloud-fan |
SparkQA
commented
Jun 24, 2019
Test build #106819 has finished for PR 24947 at commit
|
yaooqinn
commented
Jun 24, 2019
retest this please |
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Jun 24, 2019
Test build #106823 has finished for PR 24947 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Jun 24, 2019
Test build #106833 has finished for PR 24947 at commit
|
cloud-fan
commented
Jun 25, 2019
does the problem still exist when we turn on |
yaooqinn
commented
Jun 25, 2019
@cloud-fan spark.sql.parser.ansi.enabled=true works fine |
cloud-fan
commented
Jun 25, 2019
Then I think it's a parser issue(and is already fixed), we shouldn't hack |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Jun 25, 2019
Test build #106856 has finished for PR 24947 at commit
|
SparkQA
commented
Jun 25, 2019
Test build #106866 has finished for PR 24947 at commit
|
yaooqinn
commented
Jun 25, 2019
retest this please |
SparkQA
commented
Jun 25, 2019
Test build #106874 has finished for PR 24947 at commit
|
| val expectedNumberOfParameters = if (validParametersCount.length == 1) { | ||
| val expectedNumberOfParameters = if (validParametersCount.isEmpty) { | ||
| constructors.headOption.map(_.getParameterCount).getOrElse(0).toString | ||
| } else if (validParametersCount.length == 1) { |
There was a problem hiding this comment.
@yaooqinn, can you show the error message before and after this change, and fix the PR description and title? I think this PR now targets throw a better exception for the expression that has no constructors to call.
srowen
commented
Jul 16, 2019
@yaooqinn I think there are some last comments to address? |
yaooqinn
commented
Jul 17, 2019
@srowen I have updated the pr description and title as last comment required. If anything I misread, please correct me. Thanks very much. |
srowen
commented
Jul 17, 2019
@HyukjinKwon is that OK by you? |
SparkQA
commented
Jul 21, 2019
Test build #4826 has finished for PR 24947 at commit
|
| .map(_.getParameterCount).distinct.sorted | ||
| val expectedNumberOfParameters = if (validParametersCount.length == 1) { | ||
| val expectedNumberOfParameters = if (validParametersCount.isEmpty) { | ||
| constructors.headOption.map(_.getParameterCount).getOrElse(0).toString |
There was a problem hiding this comment.
Using headIption is hacky. We should follow the same logic what we are doing here.
| @@ -583,7 +583,9 @@ object FunctionRegistry { | |||
| val validParametersCount = constructors | |||
| .filter(_.getParameterTypes.forall(_ == classOf[Expression])) | |||
There was a problem hiding this comment.
If we remove this line, what is the outcome?
In this PR, the logic is to add a special case. When unable to find a constructor whose parameters are all Expressions, we use the remaining constructors. [Note, headOption means we only choose the first one] Could you please check whether we should list all of them in the error messages?
There was a problem hiding this comment.
If we remove this line, it works fine. I did this in the first commit of the pr, discussed with HyukjinKwon here
There was a problem hiding this comment.
No, It doesn't work fine.
We should only recognise the constructor with expressions because those are only able to be used in SQL. Otherwise, it shows incorrect information about possible argument combination which partially reverts #21226.
There was a problem hiding this comment.
The problem is that we have function registered in but that's unable/not supposed to to call via in(...) currently. Possibly there might be more cases like this.
SparkQA
commented
Jul 26, 2019
Test build #108197 has finished for PR 24947 at commit
|
yaooqinn
commented
Jul 26, 2019
retest this please |
SparkQA
commented
Jul 26, 2019
Test build #108226 has finished for PR 24947 at commit
|
HyukjinKwon
commented
Aug 22, 2019
Seems we're blocked by #24947 (comment), shall we close this and investigate if we can remove those functions from function registry? That way will cleanly fix this issue. |
What changes were proposed in this pull request?
SQL queries like
select 1 where in (), which miss the attribute name should throwAnalysisExceptionwithInvalid number of arguments for function inas debug message rather thanjava.lang.UnsupportedOperationException: empty.init.This problem I guess is related to this pr - #21226
How was this patch tested?
Before
After