You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/01/16 08:22:26 UTC

[GitHub] chenshao6311 opened a new issue #1762: 绑定表关系不能正确路由

chenshao6311 opened a new issue #1762: 绑定表关系不能正确路由
URL: https://github.com/apache/incubator-shardingsphere/issues/1762
 
 
   在两个绑定表关联查询的时候,我不明白为什么可以通过主表找到对应的dataNode之后,通过dataNode找到index,最后可以通过index来确定另外一个表的dataNode。
   只要我配置的dataNodes顺序不一样,关联查询到的结果就不正确。例如:
   我的配置:
   private static TableRuleConfiguration getOrderItemTableRuleConfiguration() {
           TableRuleConfiguration result = new TableRuleConfiguration();
           result.setLogicTable("t_order_item");
           result.setActualDataNodes("demo_ds_0.t_order_item_1,demo_ds_0.t_order_item_0,demo_ds_1.t_order_item_1,demo_ds_1.t_order_item_0");
           //result.setActualDataNodes("demo_ds_${0..1}.t_order_item_${[0, 1]}");
           return result;
       }
   
   private static TableRuleConfiguration getOrderTableRuleConfiguration() {
           TableRuleConfiguration result = new TableRuleConfiguration();
           result.setLogicTable("t_order");
           result.setActualDataNodes("demo_ds_${0..1}.t_order_${[0, 1]}");
           result.setKeyGeneratorColumnName("order_id");
           return result;
       }
   
   shardingRuleConfig.getBindingTableGroups().add("t_order, t_order_item");
           shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration("user_id", "demo_ds_${user_id % 2}"));
           shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("order_id", new PreciseModuloShardingTableAlgorithm()));
   
   先插入数据,再以order_id为查询条件进行关联查询,则查询不到正确的结果
            
   通过查找语句
   String sql = "SELECT i.* FROM t_order o, t_order_item i WHERE o.order_id = i.order_id and o.order_id = 292325090350071808";
   
   路由结果为:String sql = "SELECT i.* FROM t_order_0 o, t_order_item_0 i WHERE o.order_id = i.order_id and o.order_id = 292325090350071808";

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services