-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Support parameter in LIMIT clause #4529
Conversation
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.
Just a couple of minor comments and a question.
analysis.getParameters())); | ||
} | ||
catch (VerifyException e) { | ||
throw semanticException(TYPE_MISMATCH, node, "Non constant parameter value for LIMIT: %s", providedValue); |
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.
TYPE_MISMATCH is not an appropriate code for this error. Let's go with INVALID_ARGUMENTS
@Test | ||
public void testLimitInvalidRowCount() | ||
{ | ||
assertFails("SELECT * FROM t1 LIMIT 987654321098765432109876543210") |
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 happened to this 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.
It doesn't throw PrestoException
any more.
The row count used to be fetched as text and analysed in the StatementAnalyzer. After this change, a LongLiteral is instantiated in AstBuilder, and ParsingException
is thrown.
Similarly, negative values now fail in Parser.
@@ -164,8 +164,14 @@ queryNoWith: | |||
queryTerm | |||
(ORDER BY sortItem (',' sortItem)*)? | |||
(OFFSET offset=INTEGER_VALUE (ROW | ROWS)?)? | |||
((LIMIT limit=(INTEGER_VALUE | ALL)) | (FETCH (FIRST | NEXT) (fetchFirst=INTEGER_VALUE)? (ROW | ROWS) (ONLY | WITH TIES)))? | |||
; | |||
((LIMIT limitRowCount) | (FETCH (FIRST | NEXT) (fetchFirst=INTEGER_VALUE)? (ROW | ROWS) (ONLY | WITH TIES)))? |
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.
We should do the same for FETCH FIRST and OFFSET, but this can be addressed in a separate PR
2605ecb
to
73131a8
Compare
Used to throw NullPointerException
73131a8
to
6f0283d
Compare
No description provided.