dongjoon-hyun opened a new pull request, #455:
URL: https://github.com/apache/spark-connect-swift/pull/455
### What changes were proposed in this pull request?
This PR aims to support comparison, logical, and arithmetic operators in
`Column`.
- Comparison: `==`, `!=`, `<`, `<=`, `>`, `>=`
- Logical: `&&`, `||`, prefix `!`
- Arithmetic: `+`, `-`, `*`, `/`, `%`, prefix `-` (negation)
The operators build `Expression.UnresolvedFunction` with the same function
names as the Scala client (`Column.scala`): `==` → `"="`, `!=` → `"!"` of
`"="`, `&&` → `"and"`, `||` → `"or"`, prefix `-` → `"negative"`, and the same
symbols for the rest.
In addition, `DataFrame.filter(_: Column)` and `DataFrame.where(_: Column)`
overloads are added to make the operators usable.
```swift
let adults = df.filter(col("age") > lit(21) && col("name") == lit("Alice"))
let doubled = df.select((col("id") * lit(2)).alias("doubled"))
```
Note that unlike Scala, Swift allows overloading `==` with a `Column` return
type without conflicts because `Column` does not conform to `Equatable`, so the
Scala-style `===`/`=!=` operators are not needed. Misuse such as `if col("a")
== col("b")` is rejected at compile time (`cannot convert value of type
'Column' to expected condition type 'Bool'`).
### Why are the changes needed?
To allow users to write filter and projection expressions in the idiomatic
PySpark/Scala style instead of SQL strings.
### Does this PR introduce _any_ user-facing change?
No. This is a new feature addition to the unreleased `Column` API.
### How was this patch tested?
Pass the CIs with the newly added unit tests.
### 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]