-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-24536] Validate that an evaluated limit clause cannot be null #21807
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
|
Ok to test |
hvanhovell
left a comment
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.
LGTM
|
New to SQL, but it seems like the query
should work, right? I tried both on Spark without to your change and the W3Schools SQL tester and it's accepted in both, but I tried on your PR and it hits the new AnalysisException. If this is indeed an issue, it can be avoided by having the case be |
|
@NiharS yeah that makes sense. @mauropalsgraaf we missed this today (sorry about that). Can you add the null check (bonus points if you call |
|
Hey @mauropalsgraaf just wanted to check in on this. Have you run into any additional issues or have any questions for this fix? |
|
Sorry for my absence, will look into it now |
|
@hvanhovell @NiharS I've added a test case and now it works properly for the given example in the description. Regarding the comment: "make sure eval is only called once", is this what you ment? |
|
ok to test |
| case e if e.dataType != IntegerType => failAnalysis( | ||
| s"The limit expression must be integer type, but got " + | ||
| e.dataType.catalogString) | ||
| case e if e.eval().asInstanceOf[Int] < 0 => failAnalysis( |
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.
How about this:
case e => e.eval() match {
case null => failAnalysis(
s"The evaluated limit expression must not be null, but got ${limitExpr.sql}")
case v: Int if v < 0 => failAnalysis(
s"The limit expression must be equal to or greater than 0, but got $v")
case _ => // OK
}
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.
I'm personally not a fan of this because of the nesting, but I guess it's a matter of taste. Is there any guidelines for this regarding to styling? I don't have a strong opinion about this
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.
nope but it's shorter and I don't think this code makes less readable.
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.
fixed
|
Test build #93773 has finished for PR 21807 at commit
|
|
@hvanhovell Do you know what this unknown error code, -9 means? |
|
that means Jenkins build was halted unexpectedly. usually unrelated with some changes in a pr. |
|
retest this please |
|
Test build #93787 has finished for PR 21807 at commit
|
|
Test build #93805 has finished for PR 21807 at commit
|
|
retest this please |
|
Test build #93817 has finished for PR 21807 at commit
|
|
@mauropalsgraaf Could you fix the PR title? |
|
LGTM Thanks! Merged to master/2.3 |
It proposes a version in which nullable expressions are not valid in the limit clause It was tested with unit and e2e tests. Please review http://spark.apache.org/contributing.html before opening a pull request. Author: Mauro Palsgraaf <[email protected]> Closes #21807 from mauropalsgraaf/SPARK-24536. (cherry picked from commit 4ac2126) Signed-off-by: Xiao Li <[email protected]>
|
@mauropalsgraaf Do you have a JIRA ID? I can assign the ticket to you. |
What changes were proposed in this pull request?
It proposes a version in which nullable expressions are not valid in the limit clause
How was this patch tested?
It was tested with unit and e2e tests.
Please review http://spark.apache.org/contributing.html before opening a pull request.