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/05/04 05:04:18 UTC

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

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