You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "taetaetae (via GitHub)" <gi...@apache.org> on 2023/03/02 08:43:14 UTC

[GitHub] [shardingsphere] taetaetae opened a new issue, #24420: Questions between rule assignments

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

   Hello!
   
   I want to utilize shardingsphere to query the existing sharding tables at once. 
   The current database and table configuration is as follows: 
   - database name : db_0....db_3 
   - table name 
     - db_0 : sample_0...sample_9 
     - db_1 : sample_10...sample_19 
     - db_1 : sample_20...sample_29 
     - db_3 : sample_30...sample_39
   
   In this situation, how should I write the rule specification in YAML?
   
   Also, the logic that determines the database number, table number is also a situation that requires Java logic. In this case, how can I express it in YAML?
   
   Any help would be very helpful in setting this up, thanks!


-- 
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] linghengqian commented on issue #24420: Questions between rule assignments

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #24420:
URL: https://github.com/apache/shardingsphere/issues/24420#issuecomment-1738303495

   - The new SPI was introduced in the related PR at https://github.com/apache/shardingsphere/issues/22899 , this issue can now define `List<String>` via an new Row Value Expression SPI implementation.


-- 
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] FlyingZC commented on issue #24420: Questions between rule assignments

Posted by "FlyingZC (via GitHub)" <gi...@apache.org>.
FlyingZC commented on issue #24420:
URL: https://github.com/apache/shardingsphere/issues/24420#issuecomment-1451540426

   You can use groovy expression configuration in yaml, and groovy expression also supports Java syntax. 
   You can also implement the ShardingAlgorithm algorithm to define your own 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


[GitHub] [shardingsphere] linghengqian closed issue #24420: Questions between rule assignments

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian closed issue #24420: Questions between rule assignments
URL: https://github.com/apache/shardingsphere/issues/24420


-- 
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] taetaetae commented on issue #24420: Questions between rule assignments

Posted by "taetaetae (via GitHub)" <gi...@apache.org>.
taetaetae commented on issue #24420:
URL: https://github.com/apache/shardingsphere/issues/24420#issuecomment-1455700393

   Thanks for the advice @FlyingZC, I'm getting an error when I write it like below, where did I go wrong?
   
   
   ```yaml
   rules:
     - !SHARDING
       tables:
         sample:
           actualDataNodes: db$->{0..3}.sample_$->{[0,10,20,30]..[9,19,29,39]}
           tableStrategy:
             complex:
               shardingColumns: id1, id2
               shardingAlgorithmName: contentTableShardingAlgorithm
   ```
   
   ```
   Caused by: java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.Comparable (java.util.ArrayList and java.lang.Comparable are in module java.base of loader 'bootstrap')
   	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.createRange(ScriptBytecodeAdapter.java:693)
   	at Script1.run(Script1.groovy:1)
   	at org.apache.shardingsphere.infra.util.groovy.expr.HotspotInlineExpressionParser.evaluate(HotspotInlineExpressionParser.java:103)
   	at org.apache.shardingsphere.infra.util.groovy.expr.HotspotInlineExpressionParser.evaluate(HotspotInlineExpressionParser.java:90)
   	at org.apache.shardingsphere.infra.util.groovy.expr.HotspotInlineExpressionParser.splitAndEvaluate(HotspotInlineExpressionParser.java:68)
   	at org.apache.shardingsphere.infra.util.expr.InlineExpressionParser.splitAndEvaluate(InlineExpressionParser.java:78)
   	at org.apache.shardingsphere.sharding.rule.ShardingRule.getDataSourceNames(ShardingRule.java:172)
   	at org.apache.shardingsphere.sharding.rule.ShardingRule.lambda$getDataSourceNames$6(ShardingRule.java:161)
   	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
   	at org.apache.shardingsphere.sharding.rule.ShardingRule.getDataSourceNames(ShardingRule.java:161)
   	at org.apache.shardingsphere.sharding.rule.ShardingRule.<init>(ShardingRule.java:119)
   	at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:42)
   	at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:36)
   	at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:64)
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:87)
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:79)
   	at org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:67)
   	at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:90)
   	at org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:68)
   	at org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:53)
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:77)
   	at org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:65)
   	at org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:93)
   	at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:153)
   	at org.apache.shardingsphere.driver.api.yaml.YamlShardingSphereDataSourceFactory.createDataSource(YamlShardingSphereDataSourceFactory.java:95)
   	at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.createDataSource(DriverDataSourceCache.java:51)
   	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
   	at org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache.get(DriverDataSourceCache.java:45)
   	at org.apache.shardingsphere.driver.ShardingSphereDriver.connect(ShardingSphereDriver.java:51)
   	at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121)
   	at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
   	at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
   	at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
   	at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
   ```
   


-- 
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] FlyingZC commented on issue #24420: Questions between rule assignments

Posted by "FlyingZC (via GitHub)" <gi...@apache.org>.
FlyingZC commented on issue #24420:
URL: https://github.com/apache/shardingsphere/issues/24420#issuecomment-1455969419

   This seems to be a groovy expression syntax error, you can first verify your expression in the groovy console of idea.


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