Skip to content
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

Fix Sharding column not tracked through aliases #31687

Merged
merged 1 commit into from
Jun 15, 2024

Conversation

TherChenYang
Copy link
Collaborator

@TherChenYang TherChenYang commented Jun 13, 2024

Fixes #31656.

Changes proposed in this pull request:

  • Fix Sharding column not tracked through aliases
  • When there is an alias for our sharded column, errors may occur in judging the shard condition, leading to routing all tables in the database.
  • When the alias of our regular column happens to be the same as the partitioned column, it will also incorrectly judge the slice condition, resulting in an incorrect route.
-- alias for sharding column
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account) t1 WHERE aliased_account_id  = 100

-- Incorrect routing result
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_0) t1 WHERE aliased_account_id  = 100
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_1) t1 WHERE aliased_account_id  = 100

-- Correct routing result
SELECT * FROM (SELECT account_id aliased_account_id FROM t_account_0) t1 WHERE aliased_account_id  = 100
--- sharding column with alias 
SELECT * FROM (SELECT amount account_id FROM t_account) t1 WHERE account_id  = 100

-- Incorrect routing result
SELECT * FROM (SELECT amount account_id FROM t_account_0) t1 WHERE account_id  = 100

-- Correct routing result
SELECT * FROM (SELECT amount account_id FROM t_account_0) t1 WHERE account_id  = 100
SELECT * FROM (SELECT amount account_id FROM t_account_1) t1 WHERE account_id  = 100

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • 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.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.

Copy link
Member

@strongduanmu strongduanmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TherChenYang Thank you for your work, merged.

@strongduanmu strongduanmu merged commit bba7521 into apache:master Jun 15, 2024
141 checks passed
@TherChenYang TherChenYang deleted the 31656 branch January 9, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sharding column not tracked through aliases
2 participants