-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-28143][SQL] Expressions without proper constructors should throw AnalysisException #24947
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
Changes from 4 commits
4af96a1
9ca1990
15c67d6
30ef47e
a0363de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -583,7 +583,9 @@ object FunctionRegistry { | |
| val validParametersCount = constructors | ||
| .filter(_.getParameterTypes.forall(_ == classOf[Expression])) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove this line, it works fine. I did this in the first commit of the pr, discussed with HyukjinKwon here
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, It doesn't work fine.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that we have function registered |
||
| .map(_.getParameterCount).distinct.sorted | ||
| val expectedNumberOfParameters = if (validParametersCount.length == 1) { | ||
| val expectedNumberOfParameters = if (validParametersCount.isEmpty) { | ||
| constructors.headOption.map(_.getParameterCount).getOrElse(0).toString | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using headIption is hacky. We should follow the same logic what we are doing here. |
||
| } else if (validParametersCount.length == 1) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @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. |
||
| validParametersCount.head.toString | ||
| } else { | ||
| validParametersCount.init.mkString("one of ", ", ", " and ") + | ||
|
yaooqinn marked this conversation as resolved.
Outdated
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.