beliefer opened a new pull request, #44184:
URL: https://github.com/apache/spark/pull/44184

   ### What changes were proposed in this pull request?
   Many mainstream databases supports the syntax show below.
   
   **Syntax**:
   Aggregate function
   `MODE() WITHIN GROUP (ORDER BY sortSpecification)`
   
   Window function
   ```
   MODE() WITHIN GROUP (ORDER BY sortSpecification)
   [FILTER (WHERE expression)] [OVER windowNameOrSpecification]
   ```
   
   **Examples**:
   ```
   SELECT
     mode() WITHIN GROUP (ORDER BY v),
     mode() WITHIN GROUP (ORDER BY v) FILTER (WHERE k > 0)
   FROM aggr;
   ```
   
   ```
   SELECT
       employee_name,
       department,
       salary,
       mode() WITHIN GROUP (ORDER BY salary) OVER (PARTITION BY department),
       mode() WITHIN GROUP (ORDER BY salary) FILTER (WHERE department = 
'Accounting') OVER (PARTITION BY department)
   FROM basic_pays
   ORDER BY salary;
   ```
   
   
   ### Why are the changes needed?
   Support `MODE() WITHIN GROUP (ORDER BY col)`
   
   
   ### Does this PR introduce _any_ user-facing change?
   'No'.
   New feature.
   
   
   ### How was this patch tested?
   New test cases.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   'No'.
   


-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to