-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-6355] RelToSqlConverter[ORDER BY] generates an incorrect order by when NULLS LAST is used in non-projected field #3754
Conversation
@bvolpato Calcite's jira message does not allow the Fix keyword to begin with |
94003ba
to
683fbb2
Compare
6d35537
to
1ec65f4
Compare
Attempted to fix the checker errors (added annotations & handled nullness). It hadn't failed |
1ec65f4
to
61c1b8b
Compare
This test is flaky / unrelated to my changes:
|
d047d03
to
28b1ff3
Compare
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.
Otherwise this looks pretty good.
@@ -2162,6 +2162,48 @@ private SqlDialect nonOrdinalDialect() { | |||
.ok(prestoExpected); | |||
} | |||
|
|||
/** | |||
* Test case for the base case of | |||
* <a href="https://issues.apache.org/jira/browse/CALCITE-6355">[CALCITE-6355] |
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.
So far we have required the JIRA case title, the PR case title, and the comments in the code to use the exact same text.
This makes it easy to understand how these are related.
Can you please follow these guidelines?
There are lots of examples.
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.
Sorry, missed this. I've adjusted the title here -- thank you. Do I have to reword commits? Or the title of the PR will be used when merged / squashed?
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.
Eventually after the PR is accepted you will have to squash all the commits to just one, and that one will have to have the exact same message as the JIRA title, and this PR title. Moreover, the JavaDoc for the test cases related to the fix also have to have a relatively rigid format, providing the link to the jira case and the full text in the jira title.
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.
This looks fine to me, but I am not very familiar with this part of Calcite.
If anyone else who knows this better could take a look I would feel more confident.
The test shows that this is doing something good, though.
To merge this you will have to squash the commits into a single commit, and the commit message has to be exactly the JIRA title. Take a look at the other merged commits into main for examples. |
…er by when NULLS LAST is used in non-projected field
28b1ff3
to
be8917d
Compare
Done, thanks for your help @mihaibudiu! |
Quality Gate passedIssues Measures |
There are some issues in the
needNewSubQuery
->hasSortByOrdinal
method in SqlImplementor when usingRelToSqlConverter
specifyingNULLS LAST
, for some particular queries.The method
hasSortByOrdinal
fails to recognize that the order might contain nested calls. For example, we can easily produceSqlSelect -> SqlNodeList order -> SqlBasicCall (nulls last) -> SqlBasicCall (desc) -> SqlNumericLiteral
, but it can only match correctly if there's a singleSqlBasicCall
in the chain.With that, this query:
Resolves to an invalid query. Notice the order by 2, however only one field was projected (
product_id
).With my fix, it produces the correct SELECT with subquery:
(I've also provided some context at https://issues.apache.org/jira/browse/CALCITE-6355).