x782544391 commented on issue #32237:
URL:
https://github.com/apache/shardingsphere/issues/32237#issuecomment-2245189044
ShardingSphereDataSource configuration:
`@Bean("shardingSphereDatasource")
public DataSource shardingSphereDatasource(@Qualifier("druidDatasource")
DataSource druidDatasource) {
DynamicDataSource dynamicDataSource = (DynamicDataSource)
druidDatasource;
DruidDataSource druidDataSource = (DruidDataSource)
dynamicDataSource.determineTargetDataSource();
druidDataSource.setProxyFilters(Collections.singletonList(new
ShardingSphereDruidFilter()));
try {
Properties props = new Properties();
props.put(ConfigurationPropertyKey.SQL_SHOW.getKey(), false);
props.put(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE.getKey(), 10);
Map<String, DataSource> result = new HashMap<>();
result.put("test_sharding", druidDatasource);
ShardingRuleConfiguration ruleConfiguration = new
ShardingRuleConfiguration();
Properties systemLogProps = new Properties();
systemLogProps.setProperty("strategy", "complex");
systemLogProps.setProperty("algorithmClassName",
TableShardingAlgorithm.class.getName());
ruleConfiguration.getShardingAlgorithms().put(TABLE_A_SHARDING_ALGORITHM_NAME,
new ShardingSphereAlgorithmConfiguration("CLASS_BASED", systemLogProps));
ShardingTableRuleConfiguration tableRuleConfiguration = new
ShardingTableRuleConfiguration("table_a", DATA_SOURCE_NAME + ".table_a_" +
MONTH_EXPRESSION_SUFFIX);
tableRuleConfiguration.setTableShardingStrategy(new
ComplexShardingStrategyConfiguration("CREATE_TIME_UTC, ID",
SYSTEM_LOG_SHARDING_ALGORITHM_NAME));
ruleConfiguration.getTables().add(tableRuleConfiguration);
return
ShardingSphereDataSourceFactory.createDataSource("sharding_db", result,
Collections.singletonList(ruleConfiguration), props);
} catch (Exception e) {
logger.error("ShardingSphere datasource create error,Please
check the database", e);
}
return druidDatasource;
}`
actual SQL, it has two statement:
1. SELECT {some_column}
FROM table_a_20240724 a
LEFT JOIN table_b b ON {some_condition}
LEFT JOIN table_c c ON {some_condition}
LEFT JOIN table_d d ON {some_condition}
LEFT JOIN table_e e ON {some_condition}
WHERE a.CREATE_TIME_UTC BETWEEN ? AND ? ORDER BY a.CREATE_TIME_UTC
1. SELECT {some_column}
FROM table_a_20240723 a
LEFT JOIN table_b b ON {some_condition}
LEFT JOIN table_c c ON {some_condition}
LEFT JOIN table_d d ON {some_condition}
LEFT JOIN table_e e ON {some_condition}
WHERE a.CREATE_TIME_UTC BETWEEN ? AND ? ORDER BY a.CREATE_TIME_UTC
--
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]