dongjoon-hyun opened a new pull request, #449:
URL: https://github.com/apache/spark-connect-swift/pull/449
### What changes were proposed in this pull request?
This PR aims to support `DataFrame.observe` API which defines named metrics
to observe on a `DataFrame` by building a `CollectMetrics` relation.
```swift
let observedDf = df.observe("my_metrics", sum(col("id")), max(col("id")))
```
- `DataFrame.observe(_ name: String, _ expr: Column, _ exprs: Column...)`
returns an *observed* `DataFrame` that returns the same result as the input. At
least one metric column is required at compile time, like Scala's
`Dataset.observe(name:expr:exprs:)`.
- `SparkConnectClient.getCollectMetrics` assembles the `CollectMetrics`
relation following the existing static `get*` helper pattern.
Retrieving the observed metric values from
`ExecutePlanResponse.observed_metrics` will be handled in a follow-up.
### Why are the changes needed?
To provide a way to attach observable metrics (literals or aggregate
expressions) to a `DataFrame` like Apache Spark's Scala/PySpark clients. This
leverages the recently added `Column` type and aggregate functions
([SPARK-58336]).
### Does this PR introduce _any_ user-facing change?
No. This is a new API addition.
### How was this patch tested?
Pass the CIs with a newly added test case, `DataFrameTests.observe`, which
verifies that actions (`columns`, `count`, `collect`) on an observed
`DataFrame` return the same result as the input against a live Spark Connect
server (`apache/spark:4.2.0`).
### 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]