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/11/10 05:56:19 UTC

[GitHub] [shardingsphere] wushengxuan commented on issue #22025: the Aggregate Query sql report error npe

wushengxuan commented on issue #22025:
URL: https://github.com/apache/shardingsphere/issues/22025#issuecomment-1309812393

   the shardingsphere version is 5.1.0
   the setting like this
   `package com.cfmoto.vehicle.config.sharding;
   
   import com.cfmoto.vehicle.constant.ShardingConstant;
   import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
   import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
   import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
   import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
   import org.springframework.beans.factory.annotation.Qualifier;
   import org.springframework.boot.context.properties.ConfigurationProperties;
   import org.springframework.context.annotation.Bean;
   import org.springframework.stereotype.Component;
   
   import java.util.Properties;
   
   @Component
   public class CustomShardingConfiguration {
   
       static final String EVENT_PREFIX = "event-history";
       static final String RIDE_PREFIX = "ride-history";
   
   
       @Bean(name = EVENT_PREFIX + "ShardingProperties")
       @ConfigurationProperties(prefix = "sharding." + EVENT_PREFIX)
       public ShardingProperties getEventShardingProperties() {
           return new ShardingProperties();
       }
   
       @Bean(name = RIDE_PREFIX + "ShardingProperties")
       @ConfigurationProperties(prefix = "sharding." + RIDE_PREFIX)
       public ShardingProperties getRideShardingProperties() {
           return new ShardingProperties();
       }
   
       @Bean("ShardingRuleConfiguration")
       public ShardingRuleConfiguration getShardingRule(@Qualifier(EVENT_PREFIX + "ShardingProperties") ShardingProperties eventShardingProperties, @Qualifier(RIDE_PREFIX + "ShardingProperties") ShardingProperties rideShardingProperties) {
           ShardingTableRuleConfiguration eventResult = new ShardingTableRuleConfiguration(eventShardingProperties.getLogicTable(), eventShardingProperties.getActualDataNodes());
           eventResult.setTableShardingStrategy(new StandardShardingStrategyConfiguration(eventShardingProperties.getShardingColumns(), eventShardingProperties.getShardingAlgorithmKey()));
   
           ShardingTableRuleConfiguration rideResult = new ShardingTableRuleConfiguration(rideShardingProperties.getLogicTable(), rideShardingProperties.getActualDataNodes());
           rideResult.setTableShardingStrategy(new StandardShardingStrategyConfiguration(rideShardingProperties.getShardingColumns(), rideShardingProperties.getShardingAlgorithmKey()));
   
           ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
           shardingRuleConfig.getShardingAlgorithms().put(ShardingConstant.EVENT_SHARDING_ALGORITHM_KEY, new ShardingSphereAlgorithmConfiguration(ShardingConstant.EVENT_SHARDING_TYPE, new Properties()));
           shardingRuleConfig.getShardingAlgorithms().put(ShardingConstant.RIDE_SHARDING_ALGORITHM_KEY, new ShardingSphereAlgorithmConfiguration(ShardingConstant.RIDE_SHARDING_TYPE, new Properties()));
           shardingRuleConfig.getTables().add(eventResult);
           shardingRuleConfig.getTables().add(rideResult);
           return shardingRuleConfig;
       }
   }
   `
   
   **application.properties**
   `sharding.event-history.logic-table=event_history
   sharding.event-history.sharding-columns=sharding_id
   sharding.event-history.sharding-algorithm-key=event-Sharding-algorithm
   sharding.event-history.actual-data-nodes=shardingvehicle.event_history_${202109..209912}
   sharding.event-history.sharding-type=event-history-sharding
   sharding.event-history.sharding-key=event-Sharding-algorithm
   sharding.ride-history.logic-table=ride_history
   sharding.ride-history.sharding-columns=sharding_id
   sharding.ride-history.sharding-algorithm-key=ride-Sharding-algorithm
   sharding.ride-history.actual-data-nodes=shardingvehicle.ride_history_${202109..209912}
   sharding.ride-history.sharding-type=ride-history-sharding
   sharding.ride-history.sharding-key=ride-Sharding-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