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

shard failed when there is a subquery and shard column name existed in both tables #34281

Open
KolorYan opened this issue Jan 8, 2025 · 0 comments

Comments

@KolorYan
Copy link

KolorYan commented Jan 8, 2025

Bug Report

simple sql:
SELECT * FROM a WHERE pid = #{pid} AND typeIN (selecttypefrom b where pid = #{bpid} );

  1. a is a shard table, pid is shard column
  2. b is a single table, it has a column named 'pid' too
  3. in method org.apache.shardingsphere.sharding.route.engine.condition.engine.WhereClauseShardingConditionEngine#createShardingConditions(org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext, java.util.List<java.lang.Object>)
    variable columnExpressionTableNames mapping column and table, because table a and b both exist a column 'pid', so the mapping result is pid -> b, but expected is pid -> a, because b is a single table, should be ignored
image image

Which version of ShardingSphere did you use?

5.5.1

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

shard on table a_xxx

Actual behavior

shard on all tables for a

@KolorYan KolorYan changed the title shard failed when there is a subquery and shard column name existe bot tables shard failed when there is a subquery and shard column name existe both tables Jan 8, 2025
@KolorYan KolorYan changed the title shard failed when there is a subquery and shard column name existe both tables shard failed when there is a subquery and shard column name existed in both tables Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant