You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "Ayasaz (via GitHub)" <gi...@apache.org> on 2026/06/18 07:05:58 UTC

[PR] Ignore sort direction when comparing group by and order by items (#23014) [shardingsphere]

Ayasaz opened a new pull request, #38863:
URL: https://github.com/apache/shardingsphere/pull/38863

   Fixes #23014.
   
   Changes proposed in this pull request:
     - `SelectStatementBaseContext#isSameGroupByAndOrderByItems` compared the order by item lists via `equals()`, which includes the sort direction (`OrderByItem#equals` factors in `OrderDirection`). As a result a query like `GROUP BY col1, col2 ORDER BY col1 DESC, col2 DESC` was treated as having different group by / order by items.
     - That false negative caused two regressions on the same column sequence with a different direction: pagination was expanded to `LIMIT 0, 2147483647` (full fetch, see `PaginationContext#isMaxRowCount`), and the merge engine fell back from streaming to memory group merge (`ShardingDQLResultMerger#getGroupByMergedResult`).
     - Group by carries no direction by SQL semantics. When order by references the same column sequence the grouping keys stay contiguous, so streaming group merge remains valid and the original pagination can be preserved regardless of asc/desc; the direction is already honored by the merge comparator (`GroupByRowComparator`). The check now compares the item index sequence only and ignores direction.
     - Updated the unit tests that previously relied on same-column / different-direction to force the memory-merge or LIMIT-max path so they use genuinely different items, and added cases covering the fixed behavior.
   
   This follows the root-cause analysis and fix proposal from @terrymanu on the issue.
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install ...`. (Ran `test` for the affected modules `infra/binder/core`, `infra/rewrite/core`, `features/sharding/core` — all green; have not run the full multi-module `clean install`.)
   - [ ] I have made corresponding changes to the documentation. (Behavior fix only, no doc change needed.)
   - [x] I have added corresponding unit tests for my changes.
   - [ ] I have updated the Release Notes of the current development version.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Ignore sort direction when comparing group by and order by items (#23014) [shardingsphere]

Posted by "Ayasaz (via GitHub)" <gi...@apache.org>.
Ayasaz closed pull request #38863: Ignore sort direction when comparing group by and order by items (#23014)
URL: https://github.com/apache/shardingsphere/pull/38863


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org