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

   ## Bug Report
   ### Which version of ShardingSphere did you use?
   5.1.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-Proxy
   
   # max():
   SQL:
   ```
   MySQL [hireez_sharding_db]> select max(email_campaign_account_id)  from 
EMAIL_CAMPAIGN;
   +--------------------------------+
   | max(email_campaign_account_id) |
   +--------------------------------+
   |                           NULL |
   +--------------------------------+
   1 row in set (0.010 sec)
   ```
   log:
   ```
   [INFO ] 2022-05-07 02:11:25.914 [ShardingSphere-Command-16] 
ShardingSphere-SQL - Logic SQL: select max(email_campaign_account_id)  from 
EMAIL_CAMPAIGN
   [INFO ] 2022-05-07 02:11:25.914 [ShardingSphere-Command-16] 
ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, 
limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
   [INFO ] 2022-05-07 02:11:25.914 [ShardingSphere-Command-16] 
ShardingSphere-SQL - Actual SQL: database_team_default ::: select 
max(email_campaign_account_id)  from EMAIL_CAMPAIGN_TEAM_0 UNION ALL select 
max(email_campaign_account_id)  from EMAIL_CAMPAIGN_TEAM_1 UNION ALL select 
max(email_campaign_account_id)  from EMAIL_CAMPAIGN_TEAM_2
   ```
   
   # IFNULL():
   ```
   MySQL [hireez_sharding_db]> select IFNULL(max(email_campaign_account_id),0) 
from EMAIL_CAMPAIGN;
   +------------------------------------------+
   | IFNULL(max(email_campaign_account_id),0) |
   +------------------------------------------+
   |                                        0 |
   |                                        0 |
   |                                        0 |
   +------------------------------------------+
   3 rows in set (0.007 sec)
   ```
   
   ```
   [INFO ] 2022-05-07 02:14:03.723 [ShardingSphere-Command-17] 
ShardingSphere-SQL - Logic SQL: select IFNULL(max(email_campaign_account_id),0) 
from EMAIL_CAMPAIGN
   [INFO ] 2022-05-07 02:14:03.725 [ShardingSphere-Command-17] 
ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, 
limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
   [INFO ] 2022-05-07 02:14:03.725 [ShardingSphere-Command-17] 
ShardingSphere-SQL - Actual SQL: database_team_default ::: select 
IFNULL(max(email_campaign_account_id),0) from EMAIL_CAMPAIGN_TEAM_0 UNION ALL 
select IFNULL(max(email_campaign_account_id),0) from EMAIL_CAMPAIGN_TEAM_1 
UNION ALL select IFNULL(max(email_campaign_account_id),0) from 
EMAIL_CAMPAIGN_TEAM_2
   ```
   
   Maybe we need to aggregate the results again after finding the results in 
slices. Although this sounds very troublesome.
   
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to