dongjoon-hyun opened a new pull request, #448:
URL: https://github.com/apache/spark-connect-swift/pull/448

   ### What changes were proposed in this pull request?
   
   This PR aims to add shortcut aggregation methods to `GroupedData`:
   
   - `count()` — counts the number of records for each group with a `count` 
result column.
   - `sum(_ colNames: String...)`
   - `avg(_ colNames: String...)`
   - `mean(_ colNames: String...)` (an alias of `avg`)
   - `min(_ colNames: String...)`
   - `max(_ colNames: String...)`
   
   The semantics follow the Scala Spark Connect client's 
`RelationalGroupedDataset`:
   `count()` is built as `count(lit(1)).alias("count")`, and the 
column-name-based
   methods map each name via the corresponding `Column` function without 
client-side
   numeric-type validation (delegated to the server, like the Connect Scala 
client).
   All methods reuse the existing `Aggregate` relation path, so they work 
identically
   for `groupBy`, `rollup`, and `cube`.
   
   ```swift
   let df = try await spark.sql(DEALER_TABLE).groupBy("city").count()
   let df2 = try await spark.sql(DEALER_TABLE).rollup("city").sum("quantity")
   ```
   
   ### Why are the changes needed?
   
   Previously, `GroupedData` only provided `agg`. These shortcut methods provide
   feature parity with PySpark's `GroupedData` and the Scala client's
   `RelationalGroupedDataset` for the most common aggregations.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a new API addition.
   
   ### How was this patch tested?
   
   Pass the CIs with newly added test cases.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Fable 5


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