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

Enrico Minack updated SPARK-40830:
----------------------------------
    Description: 
Calling {{Dataset.groupBy(...).as[K, T]}} should be preferred over calling 
{{Dataset.groupByKey(...)}} whenever possible. The former allows Catalyst to 
exploit existing partitioning and ordering of the Dataset, while the latter 
hides from Catalyst which columns are used to create the keys.

Example:

Calling {{ds.groupByKey(_.id)}} hides from Catalyst that column id is the 
grouping key.
With {{ds.groupBy($"id").as[Int, V]}} tells Catalyst that {{ds}} is to be 
grouped by (partitioned and ordered by) column "id".

This fact should be documented. Further, {{groupByKey}} methods with {{Column}} 
and {{String}} arguments would help to short cut {{groupByKey.as}} and avoid 
the {{groupBy(func)}} methods.

  was:
Calling {{Dataset.groupBy(...).as[K, T]}} should be preferred over calling 
{{Dataset.groupByKey(...)}} whenever possible. The former allows Catalyst to 
exploit existing partitioning and ordering of the Dataset, while the latter 
hides the columns used to create the keys from Catalyst.

Example:

Calling {{ds.groupByKey(_.id)}} hides from Catalyst that column id is the 
grouping key.
With {{ds.groupBy($"id").as[Int, V]}} tells Catalyst that {{ds}} is to be 
grouped by (partitioned and ordered by) column "id".

This fact should be documented. Further, {{groupByKey}} methods with {{Column}} 
and {{String}} arguments would help to short cut {{groupByKey.as}} and avoid 
the {{groupBy(func)}} methods.


> Dataset.groupBy.as should be preferred over Dataset.groupByKey
> --------------------------------------------------------------
>
>                 Key: SPARK-40830
>                 URL: https://issues.apache.org/jira/browse/SPARK-40830
>             Project: Spark
>          Issue Type: Improvement
>          Components: Documentation, SQL
>    Affects Versions: 3.4.0
>            Reporter: Enrico Minack
>            Priority: Minor
>
> Calling {{Dataset.groupBy(...).as[K, T]}} should be preferred over calling 
> {{Dataset.groupByKey(...)}} whenever possible. The former allows Catalyst to 
> exploit existing partitioning and ordering of the Dataset, while the latter 
> hides from Catalyst which columns are used to create the keys.
> Example:
> Calling {{ds.groupByKey(_.id)}} hides from Catalyst that column id is the 
> grouping key.
> With {{ds.groupBy($"id").as[Int, V]}} tells Catalyst that {{ds}} is to be 
> grouped by (partitioned and ordered by) column "id".
> This fact should be documented. Further, {{groupByKey}} methods with 
> {{Column}} and {{String}} arguments would help to short cut {{groupByKey.as}} 
> and avoid the {{groupBy(func)}} methods.



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

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

Reply via email to