In query route error
Bug Report
Which version of ShardingSphere did you use?
4.0.0.M1
Which project did you use? Sharding-JDBC or Sharding-Proxy?
sharding-proxy
Expected behavior
sql:
select * from customer t where party_id in(8001,8002,8003,8004);
config:
customer:
actualDataNodes: ds_0.customer_000${0..1},ds_1.customer_000${2..3}
databaseStrategy:
inline:
shardingColumn: party_id
algorithmExpression: ds_${(party_id % 4).intdiv(2)}
tableStrategy:
inline:
shardingColumn: party_id
algorithmExpression: customer_${"000" + (party_id % 4)}
route result error:
ds_0 ::: select * from customer_0000 t where party_id in(8001,8002,8003,8004);
ds_0 ::: select * from customer_0001 t where party_id in(8001,8002,8003,8004);
ds_0 ::: select * from customer_0002 t where party_id in(8001,8002,8003,8004);
ds_0 ::: select * from customer_0003 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0000 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0001 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0002 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0003 t where party_id in(8001,8002,8003,8004);
The correct routing result should be as follows:
ds_0 ::: select * from customer_0000 t where party_id in(8001,8002,8003,8004);
ds_0 ::: select * from customer_0001 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0002 t where party_id in(8001,8002,8003,8004);
ds_1 ::: select * from customer_0003 t where party_id in(8001,8002,8003,8004);
@guowdxp it compute availableTargetDatabases using sharding condition, then use each availableTargetDatabases and sharding condition value compute actual table, it cause datasource Cartesian with actual table, when database sharding column is the same as table sharding column ,it execute more actual sql, but the result is correct. StandardRoutingEngine#routeDataSources method return a Map<String,List
We need to consider about some new design to enhance route results
maybe we can provide a user defined filter to get the corrected combination result.
or we can use actualDataNodes to filter the Cartesian result
duplicate with #2193