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

[GitHub] [shardingsphere] xuejmnet opened a new issue, #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   ## Question
   
   why use `isSameGroupByAndOrderByItems` in `SelectStatementContext` ,`isStartsWithGroupByInOrderByItems`  more appropriate
   
   i think sharding group merger only match startsWith 
   eg. 
   ```sql
   select a,b,count(id) idCount from table group a,b order by a,b
   select a,b,count(id) idCount from table group a,b order by a,b,idCount
   ```
   


-- 
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] yangsen00 commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   > @yangsen00 Of course. I will assign this issue to you.
   
   Hello,what should do if groupItem is not empty but orderbyItem is empty?Or ignore it?


-- 
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] strongduanmu commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   Thanks for your advice. How about `isGroupByStartsWithOrderByItems`?
   
   


-- 
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] xuejmnet commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   Of course I can, it's my pleasure. However, I don't have an environment locally to run the code. I think unit tests before submitting a pull request are very important, so I'm still sorry about this. I hope the community can help me complete this pull request. Thank 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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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


[GitHub] [shardingsphere] xuejmnet commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   > > @yangsen00 Of course. I will assign this issue to you.
   > 
   > Hello,what should do if groupItem is not empty but orderbyItem is empty?Or ignore it?
   
   if orderbyitem is empty framework will rewrite sql, append groupitem to orderbyitem。 If I remember correctly


-- 
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] strongduanmu commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   @xuejmnet Thank you for your feedback. Let's see if there is a community of developers willing to optimize this.
   


-- 
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] yangsen00 commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   > @xuejmnet Thank you for your feedback. Let's see if there is a community of developers willing to optimize this.
   
   hello,may I ?


-- 
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] strongduanmu commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   > isGroupByStartsWithOrderByItems better than isSameGroupByAndOrderByItems
   
   Yes, this is a great improve. Can you submit a pr to optimize it?


-- 
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] xuejmnet commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   @strongduanmu this is a sample
   ```java
   
       /**
        * before
        * @return
        */
       public boolean isSameGroupByAndOrderByItems() {
           return !groupByContext.getItems().isEmpty() && groupByContext.getItems().equals(orderByContext.getItems());
       }
   
       /**
        * after
        * @return
        */
       public boolean isGroupByStartsWithOrderByItems() {
           if(groupByContext.getItems().isEmpty()){
               return false;
           }
           int min = Math.min(groupByContext.getItems().size(), orderByContext.getItems().size());
           Iterator<OrderByItem> groupIterator = groupByContext.getItems().iterator();
           Iterator<OrderByItem> orderIterator = orderByContext.getItems().iterator();
           for (int i = 0; i < min; i++) {
               OrderByItem groupItem = groupIterator.next();
               OrderByItem orderItem = orderIterator.next();
               if(!Objects.equals(groupItem,orderItem)){
                   return false;
               }
           }
           return true;
       }
   ```
   isGroupByStartsWithOrderByItems better than isSameGroupByAndOrderByItems


-- 
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] strongduanmu commented on issue #25414: isStartsWithGroupByInOrderByItems more appropriate in SelectStatementContext

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

   @yangsen00 Of course. I will assign this issue to 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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

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