beliefer opened a new pull request #27058: [SPARK-30395][SQL] When one or more 
DISTINCT aggregate expressions operate on the same field, the DISTINCT 
aggregate expression allows the use of the FILTER clause
URL: https://github.com/apache/spark/pull/27058
 
 
   ### What changes were proposed in this pull request?
   This PR is related to https://github.com/apache/spark/pull/26656.
   https://github.com/apache/spark/pull/26656 only support use FILTER clause on 
aggregate expression without DISTINCT.
   This PR will enhance this feature when one or more DISTINCT aggregate 
expressions operate on the same field, the DISTINCT aggregate expression allows 
the use of the FILTER clause.
   Such as:
   ```
   select sum(distinct id) filter (where sex = 'man') from student;
   select class_id, sum(distinct id) filter (where sex = 'man') from student 
group by class_id;
   select count(id) filter (where class_id = 1), sum(distinct id) filter (where 
sex = 'man') from student;
   select class_id, count(id) filter (where class_id = 1), sum(distinct id) 
filter (where sex = 'man') from student group by class_id;
   select sum(distinct id), sum(distinct id) filter (where sex = 'man') from 
student;
   select class_id, sum(distinct id), sum(distinct id) filter (where sex = 
'man') from student group by class_id;
   select class_id, count(id), count(id) filter (where class_id = 1), 
sum(distinct id), sum(distinct id) filter (where sex = 'man') from student 
group by class_id;
   ```
   This PR not support:
   ```
   select class_id, count(distinct sex), sum(distinct id) filter (where sex = 
'man') from student group by class_id;
   select class_id, count(distinct sex) filter (where class_id = 1), 
sum(distinct id) filter (where sex = 'man') from student group by class_id;
   ```
   https://issues.apache.org/jira/browse/SPARK-30396 used for later.
   
   ### Why are the changes needed?
   No
   
   
   ### Does this PR introduce any user-facing change?
   No
   
   
   ### How was this patch tested?
   New UT
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to