penweizgx commented on issue #31443:
URL:
https://github.com/apache/shardingsphere/issues/31443#issuecomment-2138544678
@strongduanmu
t_opt_log:
actualDataNodes: db1.t_opt_log_${101}
Changing the configuration to this does work, but my physical table
db1.t_opt_log_${***} is created dynamically and cannot be determined when the
project starts; in version 5.2.1, you can first configure a non-existent table
db1.t_opt_log_0, and then route it to the corresponding table through the
custom tenantHintAlgorithm algorithm when executing SQL
```
public class TenantHintAlgorithm implements HintShardingAlgorithm<Long> {
@Override
public Collection<String> doSharding(Collection<String>
availableTargetNames, HintShardingValue<Long> shardingValue) {
Collection<String> result = new ArrayList<>();
String logicTableName = shardingValue.getLogicTableName();
for (Long value : shardingValue.getValues()) {
String newtable = logicTableName+"_"+value;
result.add(newtable);
}
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]