-
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-6063] If ARRAY subquery has ORDER BY (without LIMIT), rows are not sorted #3644
Conversation
1e3dfb4
to
23099a6
Compare
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 14 New issues |
@@ -5538,7 +5538,7 @@ ImmutableList<RelNode> retrieveCursors() { | |||
case ARRAY_QUERY_CONSTRUCTOR: | |||
call = (SqlCall) expr; | |||
query = Iterables.getOnlyElement(call.getOperandList()); | |||
root = convertQueryRecursive(query, false, null); | |||
root = convertQueryRecursive(query, true, null); |
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 think this deserves a comment. I think you are pretending this to be the toplevel query, because this will prevent ORDER BY from being eliminated.
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.
Agree. Perhaps rename boolean top
to boolean preserveOrderBy
(assuming that top
doesn't control any other behavior). Then the documentation can be on the convertQueryRecursive
method.
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.
thanks, fixed. however I still used top, The current codepath is passed in from top all the way. top is also easy to understand.
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.
You force-pushed?!
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.
You force-pushed?!
Sorry, I know the rules for review, but I accidentally force-push it ..
site/_docs/reference.md
Outdated
|
||
| Operator syntax | Description | | ||
|:-----------------------------------|:------------| | ||
| ARRAY (sub-query) | Creates an array from the result of a sub-query. Example: `ARRAY(SELECT empno FROM emp)` | |
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.
maybe add ORDER BY
to example, to illustrate that it is possible
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.
Added it.
8c978fc
to
0265ec5
Compare
0265ec5
to
de9a0fa
Compare
I have updated the PR to fix:
It should be noted that there are some differences between ARRAY subquery and MULTISET/MAP subquery. Please refer to the comments of the CALCITE-6063 for details. We may decide to make some improvements in follow-up issues or PRs. |
Hi guys. Sorry, I accidentally forced-push PR instead of a new commit, but there are no new lines affecting the logic, only the test cases for map/multiset. If there are no other comments, I will merge it later. Thanks for reviewing it! |
merging... |
issue:
https://issues.apache.org/jira/browse/CALCITE-6063
context:
The sql-standard-2003 allows array constrcutor by query:
and calcite does support it.
however the orderby was removed by the issue https://issues.apache.org/jira/browse/CALCITE-2978.
The solution of this PR is same as #1763 to allow sort in subquery.