FlyingZC commented on issue #18207:
URL: 
https://github.com/apache/shardingsphere/issues/18207#issuecomment-1171866668

   I will do this.
   
   # formatted sql
   ## count
   Logic SQL:
   
   ```sql
   select
       count(accesslog0_.id) as col_0_0_
   from
       ACCESS_LOG accesslog0_
   where
       accesslog0_.create_time >= ?
       and accesslog0_.create_time < ?
   ```
   
   Actual SQL:
   
   ```sql
   select
       count(accesslog0_.id) as col_0_0_
   from
       ACCESS_LOG_W202223 accesslog0_
   where
       accesslog0_.create_time >= ?
       and accesslog0_.create_time < ?
   UNION
   ALL
   select
       count(accesslog0_.id) as col_0_0_
   from
       ACCESS_LOG_W202224 accesslog0_
   where
       accesslog0_.create_time >= ?
       and accesslog0_.create_time < ?
   UNION
   ALL
   select
       count(accesslog0_.id) as col_0_0_
   from
       ACCESS_LOG_W202225 accesslog0_
   where
       accesslog0_.create_time >= ?
       and accesslog0_.create_time < ?
   
   [2022-05-01 00:00:00.0, 2022-07-01 00:00:00.0, 2022-05-01 00:00:00.0, 
2022-07-01 00:00:00.0, 2022-05-01 00:00:00.0, 2022-07-01 00:00:00.0]
   ```
   shardingsphere generated "UNION ALL" rather then add up the results
   
   ## group by
   Logic SQL:
   
   ```sql
   select
       infolog0_.method as col_0_0_,
       count(distinct infolog0_.actorId) as col_1_0_,
       count(infolog0_.id) as col_2_0_
   from
       set_info_logs infolog0_
   where
       infolog0_.startTime >= ?
       and infolog0_.startTime <= ?
   group by
       infolog0_.method
   order by
       count(infolog0_.id) DESC
   limit
       ?
   ```
   
   Actual SQL:
   
   ```sql
   select
       DISTINCT infolog0_.method as col_0_0_,
       infolog0_.actorId as col_1_0_,
       count(infolog0_.id) as col_2_0_
   from
       set_info_logs_202206 infolog0_
   where
       infolog0_.startTime >= ?
       and infolog0_.startTime <= ?
   order by
       count(infolog0_.id) DESC
   limit
       ? 
   
   [2022-06-01 00:00:00.0, 2022-07-07 00:00:00.0, 2147483647]
   ```
   shardingsphere generated sql without "goup by".


-- 
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-unsubscr...@shardingsphere.apache.org

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

Reply via email to