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

   
   Fixes #39865.
   
   Changes proposed in this pull request:
     - `ShardingOrderByTokenGenerator` used 
`ColumnOrderByItemSegment.getText()` and `OrderByToken` only implemented 
`Attachable`, so the generated ORDER BY kept the logic table owner on every 
route unit: `SELECT t_account.status, COUNT(*) FROM t_account GROUP BY 
t_account.status` became `... FROM t_account_0 GROUP BY t_account_0.status 
ORDER BY t_account.status ASC ` and failed on the database (same defect as 
#18122).
     - Make `OrderByToken` `RouteUnitAware` with per-route-unit item texts, 
mirroring `ProjectionsToken`.
     - Make `ShardingOrderByTokenGenerator` `RouteContextAware` with 
`ShardingRule` injected; resolve owners through 
`ShardingTokenUtils.getLogicAndActualTableMap()` (binding tables included) when 
`TableExtractor.needRewrite()` accepts them. Alias, unqualified and unmapped 
owners keep their text and quotes.
     - Update `ShardingOrderByTokenGeneratorTest` and `OrderByTokenTest` for 
`toString(routeUnit)`; add owner, quoted owner, binding table, alias and 
unmapped owner cases.
     - Add two table-owner cases to the rewriter IT `select.xml`; both fail on 
master.
     - Verification scope: `./mvnw install -pl features/sharding/core -am -B 
-T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e` (BUILD SUCCESS, 882 tests, 0 
failures), `ShardingSQLRewriterIT` in `test/it/rewriter` (780 cases, 0 
failures), spotless, checkstyle and apache-rat with `-Pcheck`; full-repository 
`clean install` and E2E not run locally.
   
   AI assistance: Claude Code was used to draft the change, its unit tests in 
`features/sharding/core`, and the rewriter IT cases in `test/it/rewriter`. I 
reviewed and verified every line submitted.
   
   ---
   
   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 -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`. Ran the module-scoped equivalent 
instead: `./mvnw install -pl features/sharding/core -am -B -T1C 
-Dmaven.javadoc.skip -Dmaven.jacoco.skip -e` (BUILD SUCCESS), `./mvnw -pl 
test/it/rewriter -am test -Dtest=ShardingSQLRewriterIT` (780 cases passed), and 
`spotless:apply`, `checkstyle:check`, `apache-rat:check` with `-Pcheck` on 
`features/sharding/core` and `test/it/rewriter`.
   - [ ] I have made corresponding changes to the documentation. No user-facing 
documentation describes this rewrite; none needed.
   - [x] I have added corresponding unit tests for my changes.
   - [x] I have updated the Release Notes of the current development version. 
For more details, see [Update Release 
Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
   - [x] I have disclosed the tool and affected files or scope for any material 
AI assistance, as required by the [AI-assisted contribution policy].
   
   [AI-assisted contribution policy]: 
https://github.com/apache/shardingsphere/blob/master/AI_POLICY.md
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to