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/12/21 11:19:02 UTC

[GitHub] [shardingsphere] H-Jason commented on issue #23014: SelectStatementContext#isSameGroupByAndOrderByItems has bug

H-Jason commented on issue #23014:
URL: https://github.com/apache/shardingsphere/issues/23014#issuecomment-1361188545

   > Hi @H-Jason, thank you for your feedback. Can you provide your configuration and table init sql to help us reproduce this exception?
   i just shard two table in one database;you can reproduct in any table ;
   `
   public class ShardByTableOperator {
       public ShardingRuleConfiguration buildShardConfig() {
           String shardField = "identifier";
           ShardingTableRuleConfiguration mainTableRuleConfig = new ShardingTableRuleConfiguration("MY_TABLE",
               "DBNAME.MY_TABLE{[0, 1]}");
           List<ShardingTableRuleConfiguration> tableRules = new ArrayList<>();
           tableRules.add(mainTableRuleConfig);
           ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
           shardingRuleConfig.getTables().addAll(tableRules);
           shardingRuleConfig.setDefaultTableShardingStrategy(
               new StandardShardingStrategyConfiguration(shardField, "my_algorithm"));
           shardingRuleConfig.getShardingAlgorithms()
               .put("my_algorithm", new ShardingSphereAlgorithmConfiguration("my_algorithm", new Properties()));
           return shardingRuleConfig;
       }
   }
   
   public class PreciseModuloShardingTableAlgorithm implements StandardShardingAlgorithm<String> {
   
       private Properties props;
   
       @Override
       public String doSharding(final Collection<String> tableNames, final PreciseShardingValue<String> shardingValue) {
           for (String each : tableNames) {
               int a = (shardingValue.getValue().hashCode() & Integer.MAX_VALUE) % 2;
               if (each.endsWith(String.valueOf(a))) {
                   return each;
               }
           }
           throw new UnsupportedOperationException();
       }
   
      @Override
       public String getType() {
           return "my_algorithm";
       }
   }`
   


-- 
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