ryapandt opened a new issue, #1916:
URL: https://github.com/apache/cloudberry/issues/1916

   ### Apache Cloudberry version
   
   Cloudberry 2.1.0
   
   ### What happened
   
   Cloudberry 2.1.0 may return inconsistent results for two semantically 
equivalent aggregate expressions.
   
   The following two expressions should always return the same result:
   
   ```sql
   COUNT(DISTINCT goods_gid) FILTER (WHERE invqty = 0)
   
   COUNT(DISTINCT CASE WHEN invqty = 0 THEN goods_gid END)
   ```
   However, in our environment, these two expressions return different values.
   
   This is a correctness issue because the query result is incorrect.
   
   ### What you think should happen instead
   
   _No response_
   
   ### How to reproduce
   
   ```
   CREATE TABLE test_cnt
   (
       goods_gid int,
       invqty int
   )
   DISTRIBUTED BY (goods_gid);
   
   
   INSERT INTO test_cnt VALUES
   (1,0),
   (1,1),
   (2,0),
   (2,0),
   (3,1);
   
   
   SELECT
       COUNT(DISTINCT goods_gid)
           FILTER (WHERE invqty = 0) AS cnt1,
   
       COUNT(DISTINCT CASE
           WHEN invqty = 0 THEN goods_gid
       END) AS cnt2
   FROM test_cnt;
   ```
   
   ### Operating System
   
   rocky linux 9.6
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes, I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/cloudberry/blob/main/CODE_OF_CONDUCT.md).
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to