You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "L. C. Hsieh (Jira)" <ji...@apache.org> on 2026/02/20 21:31:00 UTC

[jira] [Assigned] (SPARK-55322) Add Overload for MaxBy / MinBy with k > 1

     [ https://issues.apache.org/jira/browse/SPARK-55322?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

L. C. Hsieh reassigned SPARK-55322:
-----------------------------------

    Assignee: Alexis Schlomer

> Add Overload for MaxBy / MinBy with k > 1
> -----------------------------------------
>
>                 Key: SPARK-55322
>                 URL: https://issues.apache.org/jira/browse/SPARK-55322
>             Project: Spark
>          Issue Type: New Feature
>          Components: SQL
>    Affects Versions: 4.2.0
>            Reporter: Alexis Schlomer
>            Assignee: Alexis Schlomer
>            Priority: Major
>              Labels: pull-request-available
>
> Adds an optional *k* parameter to {{max_by}} / {{min_by}} to return top-K (or bottom-K) values per group, enabling concise, intent-clear queries and native window-function usage. This replaces complex CTE and ranking patterns with a single aggregation that returns an array of up to _k_ values of {{expr1}} ordered by {{expr2}} (ties non-deterministic; NULL order keys excluded). The implementation uses a bounded priority queue during aggregation, avoiding full sorts and large materialization overhead, and aligns Spark with functionality already available in engines like Snowflake, DuckDB, and Trino.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org