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

[GitHub] [shardingsphere] yflytom opened a new issue, #25470: The shard key has no value, how to rewrite the shardingjdbc source code to set the query table range, and query all without specifying

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

   ## Question
   
   **For English only**, other languages will not accept.
   
   The shard key has no value, how to override the shardingjdbc source code to set the query table range, and query all tables without specifying it
   
   分片key没有值,如何重写shardingjdbc源码,来设置查询表范围,不指定就查询了所有配置的表,
   
   我的配置:
   
   ```yml
       rules:
         sharding:
           # 数据分片配置
           tables:
             event_signal_his:
   #            actual-data-nodes: sharding_station.event_signal_his_2022${['07','08','09','10','11','12']},sharding_station.event_signal_his_2023${['01','02','03']}
               actual-data-nodes: sharding_station.event_signal_his_2022${['07','08','09','10','11','12']},sharding_station.event_signal_his_$->{2023..2050}$->{(1..12).collect(i->i.toString().padLeft(2,'0'))}
               # 分表策略
               table-strategy:
                 standard:
                   # 分表字段
                   sharding-column: HAPPEN_TIME
                   # 自定义名称
                   sharding-algorithm-name: event-signal-his-alg
             target_collection_his:
   #            actual-data-nodes: sharding_station.target_collection_his_2022${['07','08','09','10','11','12']},sharding_station.target_collection_his_2023${['01','02','03']}
               actual-data-nodes: sharding_station.target_collection_his_2022${['07','08','09','10','11','12']},sharding_station.target_collection_his_$->{2023..2050}$->{(1..4).collect(i->i.toString().padLeft(2,'0'))}
               table-strategy:
                 standard:
                   sharding-column: COLLECT_TIME
                   sharding-algorithm-name: target-collection-his-alg
           #        binding-tables:  # 绑定表,也就是实际上哪些配置的sharidng表规则需要实际生效的列表,配置为yaml列表,并且允许单个条目中以逗号切割,所配置表必须已经配置为逻辑表
           #          - event_signal_his,需要链表的表
           # 分片算法配置
           sharding-algorithms:
             event-signal-his-alg: # 分片算法名称
               type: CLASS_BASED # 声明类引用
               props: # 分片算法属性配置
                 strategy: STANDARD
                 algorithmClassName: com.nrec.integration.sharding.alg.YearMonthShardingAlgorithm
             target-collection-his-alg:
               type: CLASS_BASED
               props:
                 strategy: STANDARD
                 algorithmClassName: com.nrec.integration.sharding.alg.YearMonthShardingAlgorithm
   ```
   I have configured a custom sharding policy, but when the shard key is not specified or has no value, the custom sharding policy will not be used
   
   我配置了自定义分片策略,但是当分片键不指定或者没有值时,是不会走自定义分片策略
   
   Find many ways to intercept through SQL, but it is difficult to modify SQL and parse (SQL has more nested logic in SQL), so I want to modify the scope of the query table by rewriting the shardingjdbc source code, and give the shard key a start and end date
   
   找了很多方法通过sql拦截,但是难度较大需要修改sql以及解析(sql内部嵌套逻辑较多),所以想通过重写shardingjdbc源码来修改查询表的范围,给分片键一个开始结束日期
   
   Which class method in the source code should be rewritten to implement the requirements above
   
   应该重写源码中的哪个类方法实现上面的需求


-- 
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] yflytom commented on issue #25470: The shard key has no value, how to rewrite the shardingjdbc source code to set the query table range, and query all without specifying

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

   > 你好@yflytom 我想你可以参考#25208, master 分支现在支持无分片键的路由。
   I see a feature that seems to have been launched in version 5.4, but it has not been officially used yet, is there any other way to solve it
   我看到了好像是在5.4版本推出的功能,但是还没有推出正式使用,有没有其他方法解决


-- 
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] RaigorJiang commented on issue #25470: The shard key has no value, how to rewrite the shardingjdbc source code to set the query table range, and query all without specifying

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

   Hi @yflytom 
   I think you can refer to #25208, the master branch now supports routing without sharding key.


-- 
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] RaigorJiang commented on issue #25470: The shard key has no value, how to rewrite the shardingjdbc source code to set the query table range, and query all without specifying

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

   You can build binary from the master branch for testing. 


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