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 2020/11/30 11:35:39 UTC

[GitHub] [shardingsphere] tristaZero opened a new issue #7531: Improvement on subquery handling in ShardingRouteDecorator

tristaZero opened a new issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531


   
   ### Requisites
   1. Have the basic learning about `ShardingStatementValidator`
   2. Java coding
   ---
   ### Aim-1
   1. This issue is to do some refactoring works to make the subquery validating cohesive.
   
   ### How-1
   1. Create a class`ShardingSelectStatementValidator` implements `ShardingStatementValidator`.
   2. Move the content of `checkSubqueryShardingValues` in `ShardingRouteDecorator` to the preValidate of `ShardingSelectStatementValidator`.
   ---
   
   Once `How-1` finishes, you can raize a PR. Moreover, there is a further to-do for Aim-2.
   ### Aim-2
   1. Review the validating logic and make all the subqueries in the `one database instance` run well. FYI, currently, subquery only with the same sharding key can work well, which limits the subquery supported scope where we can reach.
   
   ### How-2
   1. Review the preValidate function and fill the postValidate function in `ShardingSelectStatementValidator` to make the subqueries SQL routed in the same instance work well.
   2. Fix the @Ignore tests in `SubqueryRouteTest`
   3. Add a test case with a subquery SQL containing different sharding column names, like using order_id and item_id together.
   
   
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] sluk3r commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
sluk3r commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-696523859






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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-696560079


   Hi @sluk3r welcome!
   After finishing the `how-1`, a PR is supposed to raize. The task of `how-2` is uneasy. Please give it more consideration. :-)


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-696560079


   Hi @sluk3r welcome!
   After finishing the `how-1`, a PR is supposed to raize. The task of `how-2` is uneasy. Please give it more consideration. :-)


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-732682370


   @strongduanmu hi, I've modified the codes according to your suggestion.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-736381065


   > I'd like to take care of aim-2.
   
   @wgy8283335 Welcome ! 👍


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero edited a comment on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-718353208


   It looks @sluk3r is unavailable to give us some feedback. Therefore, we have to seek support from the community to continue with one. 
   
   Hi, @cenyu00  @johnny2002
   Apologies for my direct approach, your demonstrable contribution to the community prompted me to contact you about this issue. Would you like to make some effort to move this issue forward? :-)
   
   Do not worry, it is not so difficult. Also @strongduanmu will give helpful suggestion if you need. Please let me know if it attracts your interest. Note, `JUST ONE contributor` is wanted here, so the first one commenting will be the new assignee.
   Look forward to hearing back from you!


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-725260102


   I'd like to take care of this issue.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-735732419


   I'd like to take care of aim-2.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-725266595


   @wgy8283335 Welcome :-) Assigned and GL.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-711485636


   > @sluk3r Hi, is there any progress? If you encounter any problems, I am willing to help. 😀
   
   👍 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-715861217


   Hi @sluk3r If you have no enough time for this issue recently, please ping me and we could consider reassign it to others. :)
   If you wanna continue with this one, please give us a reply here.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-718353208


   It looks @sluk3r is unavailable to give us some feedback. Therefore, we have to seek support from the community to continue with one. 
   
   Hi, @cenyu00  @johnny2002
   Apologies for my direct approach, your demonstrable contribution to the community prompted me to contact you about this issue. Would you like to make some effort to move this issue forward? :-)
   Do not worry, it is not so difficult. Also @strongduanmu will give helpful suggestion if you need. Please let me know if it attracts your interest. Note, `JUST ONE contributor` is wanted here, so the first one commenting will be the new assignee.
   Look forward to hearing back from you!


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-726432025


   @tristaZero "ShardingRouteDecorator" that is mentioned in "HOW-1" does not exist. Has it been changed the name to “ShardingSQLRouter.java ”?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-726438959


   I've move checkSubqueryShardingValues() to ShardingSQLRouter.java. but the check of sharding conditions is deprecated, as shardingConditions is not in the input parameters of preValidate().
   
   ```
   public final class ShardingSelectStatementValidator extends ShardingDMLStatementValidator<SelectStatement> {
       
       @Override
       public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<SelectStatement> sqlStatementContext, 
                               final List<Object> parameters, final ShardingSphereSchema schema) {
           for (String each : sqlStatementContext.getTablesContext().getTableNames()) {
               Optional<TableRule> tableRule = shardingRule.findTableRule(each);
               if (tableRule.isPresent() && isRoutingByHint(shardingRule, tableRule.get())
                   && !HintManager.getDatabaseShardingValues(each).isEmpty() && !HintManager.getTableShardingValues(each).isEmpty()) {
                   return;
               }
           }
       }
       
       @Override
       public void postValidate(final SelectStatement sqlStatement, final RouteContext routeContext) {
   
       }
   
       private boolean isRoutingByHint(final ShardingRule shardingRule, final TableRule tableRule) {
           return shardingRule.getDatabaseShardingStrategyConfiguration(tableRule) instanceof HintShardingStrategyConfiguration
               && shardingRule.getTableShardingStrategyConfiguration(tableRule) instanceof HintShardingStrategyConfiguration;
       }
   }
   
   ```


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-711175106


   @sluk3r Hi, is there any progress? If you encounter any problems, I am willing to help. 😀


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] sluk3r commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
sluk3r commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-696565368


   > Hi @sluk3r welcome!
   > After finishing the `how-1`, a PR is supposed to raize. The task of `how-2` is uneasy. Please give it more consideration. :-)
   
   Ok, Tks


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu closed issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] sluk3r commented on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
sluk3r commented on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-696523859


   please assign it to me


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] wgy8283335 removed a comment on issue #7531: Improvement on subquery handling in ShardingRouteDecorator

Posted by GitBox <gi...@apache.org>.
wgy8283335 removed a comment on issue #7531:
URL: https://github.com/apache/shardingsphere/issues/7531#issuecomment-726438959


   I've move checkSubqueryShardingValues() to ShardingSQLRouter.java. but the check of sharding conditions is deprecated, as shardingConditions is not in the input parameters of preValidate().
   
   ```
   public final class ShardingSelectStatementValidator extends ShardingDMLStatementValidator<SelectStatement> {
       
       @Override
       public void preValidate(final ShardingRule shardingRule, final SQLStatementContext<SelectStatement> sqlStatementContext, 
                               final List<Object> parameters, final ShardingSphereSchema schema) {
           for (String each : sqlStatementContext.getTablesContext().getTableNames()) {
               Optional<TableRule> tableRule = shardingRule.findTableRule(each);
               if (tableRule.isPresent() && isRoutingByHint(shardingRule, tableRule.get())
                   && !HintManager.getDatabaseShardingValues(each).isEmpty() && !HintManager.getTableShardingValues(each).isEmpty()) {
                   return;
               }
           }
       }
       
       @Override
       public void postValidate(final SelectStatement sqlStatement, final RouteContext routeContext) {
   
       }
   
       private boolean isRoutingByHint(final ShardingRule shardingRule, final TableRule tableRule) {
           return shardingRule.getDatabaseShardingStrategyConfiguration(tableRule) instanceof HintShardingStrategyConfiguration
               && shardingRule.getTableShardingStrategyConfiguration(tableRule) instanceof HintShardingStrategyConfiguration;
       }
   }
   
   ```


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org