happypleasure opened a new issue #14335:
URL: https://github.com/apache/shardingsphere/issues/14335
## Exception message
Cause: org.apache.shardingsphere.infra.exception.ShardingSphereException:
Route table t_test_66 does not exist, available actual table: [t_test_00,
t_test_01, t_test_02, t_test_03, t_test_04, t_test_05, t_test_06, t_test_07,
t_test_08, t_test_09]] with root cause
## Dependent jar
```
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.0.0</version>
</dependency>
```
## YAML Configuration
```
tables:
t_test:
actualDataNodes:
write_ds0.t_test_0${0..9},write_ds1.t_test_1${0..9},write_ds2.t_test_2${0..9},write_ds3.t_test_3${0..9},write_ds4.t_test_4${0..9},write_ds5.t_test_5${0..9},write_ds6.t_test_6${0..9},write_ds7.t_test_7${0..9},write_ds8.t_test_8${0..9},write_ds9.t_test_9${0..9}
databaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_test_db_inline
tableStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: t_test_table_inline
shardingAlgorithms:
t_test_db_inline:
type: INLINE
props:
algorithm-expression: "write_ds${Math.abs(user_id.hashCode() % 100) /
10}"
t_test_table_inline:
type: INLINE
props:
algorithm-expression: "t_test_${def num = Math.abs(user_id.hashCode()
% 100); return num > 9 ? num : '0' + num}"
```
## Execute SQL
```
select * from t_test where user_id = #{userId}
```
## Reason analyze
- use shardingsphere-jdbc-core.5.0.0-alpha version can be executed correctly
- debug error location
- shardingsphere-jdbc-core.5.0.0
-
org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy#doSharding
```
private Collection<String> doSharding(final Collection<String>
availableTargetNames, final ListShardingConditionValue<?> shardingValue) {
Collection<String> result = new LinkedList<>();
for (Comparable<?> each : shardingValue.getValues()) {
String target;
target = shardingAlgorithm.doSharding(availableTargetNames, new
PreciseShardingValue(shardingValue.getTableName(),
shardingValue.getColumnName(), each));
if (null != target && availableTargetNames.contains(target)) {
result.add(target);
} else if (null != target &&
!availableTargetNames.contains(target)) {
throw new ShardingSphereException(String.format("Route table
%s does not exist, available actual table: %s", target, availableTargetNames));
}
}
return result;
}
```
- shardingsphere-jdbc-core.5.0.0-alpha
-
org.apache.shardingsphere.sharding.route.strategy.type.standard.StandardShardingStrategy#doSharding
```
private Collection<String> doSharding(final Collection<String>
availableTargetNames, final ListShardingConditionValue<?> shardingValue) {
Collection<String> result = new LinkedList<>();
for (Comparable<?> each : shardingValue.getValues()) {
String target;
target = shardingAlgorithm.doSharding(availableTargetNames, new
PreciseShardingValue(shardingValue.getTableName(),
shardingValue.getColumnName(), each));
if (null != target && availableTargetNames.contains(target)) {
result.add(target);
}
}
return result;
}
```
--
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]