You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/10/10 06:30:33 UTC

[GitHub] [shardingsphere] q3056917665 opened a new issue, #17890: Multiple metadata OR All tables must be in the same datasource

q3056917665 opened a new issue, #17890:
URL: https://github.com/apache/shardingsphere/issues/17890

   version:
   ```
   <dependency>
   	<groupId>org.apache.shardingsphere</groupId>
   	<artifactId>shardingsphere-jdbc-core</artifactId>
   	<version>5.1.1</version>
   </dependency>
   ```
   question:
   All tables must be in the same datasource.
   
   This problem is caused by the two tables in different databases
   
   demand:
   I have multiple different logic libraries,I want to query in the same SQL,But now Sharding loads multiple data sources into a single metadata,Is there a way to get multiple data sources into different metadata.
   ![image](https://user-images.githubusercontent.com/49391495/169951152-8fa041cd-fd02-4a56-a160-22b94bc38abe.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] closed issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #17890: Multiple metadata OR All tables must be in the same datasource
URL: https://github.com/apache/shardingsphere/issues/17890


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] q3056917665 commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
q3056917665 commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1136663331

   > Could you should us your rule configurations?
   
   ```
           Map<String, DataSource> dataSourceMap = new HashMap<>();
           dataSourceMap.put("ds", dataSource);
           dataSourceMap.put("dsweixin", dataSourceWeixin);
           dataSourceMap.put("dspay", dataSourcePay);
   
           //TableRuleConfiguration testTableRuleConfig = new TableRuleConfiguration("t_sharding_jdbc","ds.t_sharding_jdbc_${0..1}");
   
           List<ShardingTableRuleConfiguration> tableRuleConfigs = getTableRuleConfigs();
   
           // 配置分片规则
           ShardingRuleConfiguration shardingRuleConfiguration = new ShardingRuleConfiguration();
   
           for (ShardingTableRuleConfiguration tableRuleConfig : tableRuleConfigs) {
               shardingRuleConfiguration.getTables().add(tableRuleConfig);
   
   
           }
           Properties datePreciseShardingAlgorithmProps = new Properties();
           datePreciseShardingAlgorithmProps.setProperty("strategy", "STANDARD");
           datePreciseShardingAlgorithmProps.setProperty("algorithmClassName", monthDateStandardShardingAlgorithm.getClass().getName());
           shardingRuleConfiguration.getShardingAlgorithms().put("monthDateStandardShardingAlgorithm", new ShardingSphereAlgorithmConfiguration(monthDateStandardShardingAlgorithm.getType(), datePreciseShardingAlgorithmProps));
   
           Properties properties = new Properties();
           properties.setProperty("sql-show", "true");
           properties.setProperty("check-duplicate-table-enabled", "true");
           properties.setProperty("check-table-metadata-enabled ", "true");
           properties.setProperty("max.connections.size.per.query", "200");
           properties.setProperty("sql-federation-enabled", "true");
           // 获取数据源对象
           try {
               //创建sharding数据源
               logger.info("sharding开始创建数据源");
               long time = System.currentTimeMillis();
               DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(dataSourceMap, Lists.newArrayList(shardingRuleConfiguration), properties);
               logger.info("sharding创建数据源结束,time:{}", (System.currentTimeMillis() - time));
               return dataSource;
           } catch (SQLException throwables) {
               logger.info("ShardingSphereConfig 创建ShardingDataSource失败", throwables);
   
           }
           return dataSource;
   ```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] q3056917665 commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
q3056917665 commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1136667670

   @TeslaCN 
   Now it is added “sql-federation-enabled”, there is no “All tables must be in the same datasource”, But appeared ClassCastException, because the two tables of the associated query are in different libraries, so I still want to know how to create multivariate data, which was supported in 4.1.1 before


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1137051658

   @q3056917665 Query tables in different databases required SQL federation. Please show us your SQL and the error after SQL federation enabled.
   Hi @strongduanmu, could you please take a look at this?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] q3056917665 commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
q3056917665 commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1137151135

   > @q3056917665 Query tables in different databases required SQL federation. Please show us your SQL and the error after SQL federation enabled. Hi @strongduanmu, could you please take a look at this?
   @strongduanmu 
   ```
    SELECT oc.record_date, SUM(oc.total_count),SUM(current_teacher_active_count) FROMcorp_operate_org_count cooc INNER JOIN system_event_org_count oc ON oc.orgcode = cooc.orgcode AND oc.record_date = cooc.record_date  WHERE cooc.providerid IN ?1 AND cooc.record_date between ?2 AND ?3 AND cooc.is_apply = 0 AND oc.event_configid = 36 GROUP BY oc.record_date 
   ```
   
   ![image](https://user-images.githubusercontent.com/49391495/170256793-916a7108-822a-4c5e-9b5f-0a6b39e189d2.png)
   
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1272349747

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] duWubiao commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
duWubiao commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1138355004

   Is there a solution to this problem?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] TeslaCN commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1136661903

   Could you should us your rule configurations?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on issue #17890: Multiple metadata OR All tables must be in the same datasource

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #17890:
URL: https://github.com/apache/shardingsphere/issues/17890#issuecomment-1137065907

   Ok, I will check it.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org