tdcmeehan opened a new pull request, #452:
URL: https://github.com/apache/spark-connect-rust/pull/452

   ### What changes were proposed in this pull request?
   
   [SPARK-61287](https://issues.apache.org/jira/browse/SPARK-61287): keep the 
column as the left operand of a reflected `&` and `|` in the Python client, as 
PySpark does.
   
   - `Column.__rand__` and `Column.__ror__` in 
`crates/pyspark-rs/src/column.rs` now build `self AND other` and `self OR 
other`. They built `other AND self` and `other OR self`.
   - Offline test 
`test_reflected_and_or_keep_the_column_as_the_left_operand_as_pyspark` in 
`python/tests/test_dropin_offline.py` checks the plan of `True & col`, `True | 
col`, `False & col` and `False | col`, and that `col & True` and `col | True` 
are unchanged.
   - Live test `test_reflected_and_or_name_the_column_first_as_pyspark` in 
`python/tests/test_dropin_e2e.py` checks that the columns of `df.select(True & 
F.col("b"), True | F.col("b"))` are `['(b AND true)', '(b OR true)']`, as the 
reference client returns them.
   
   ### Why are the changes needed?
   
   In PySpark, `True & col` and `True | col` build `(col AND true)` and `(col 
OR true)`, because `Column.__rand__` and `Column.__ror__` keep the column as 
the left operand. The Python client built `(true AND col)` and `(true OR col)`, 
so the names of the resulting columns differed from PySpark's. Against an OSS 
Spark 4.3.0 Connect server:
   
   - pyspark-client 4.3.0: `['(b AND true)', '(b OR true)']`
   - before this change: `['(true AND b)', '(true OR b)']`
   - after this change: `['(b AND true)', '(b OR true)']`
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, the name of the column that a reflected `&` or `|` creates now matches 
PySpark's: `(b AND true)` where the client named it `(true AND b)`. The value 
of the expression is unchanged, because AND and OR are commutative.
   
   ### How was this patch tested?
   
   - New offline test 
`test_reflected_and_or_keep_the_column_as_the_left_operand_as_pyspark` 
(`python/tests/test_dropin_offline.py`): the function and argument order of 
`True & col`, `True | col`, `False & col` and `False | col`, and `col & True` 
and `col | True` unchanged.
   - New live test `test_reflected_and_or_name_the_column_first_as_pyspark` 
(`python/tests/test_dropin_e2e.py`): `.columns` is `['(b AND true)', '(b OR 
true)']`, as pyspark-client 4.3.0 returns on the same server.
   - Both new tests fail on the previous build and pass with this change.
   - `cargo test -p apache-spark-connect --release --lib` (528 passed), the 
build of all tests, also with `wasm-udf`, and `cargo fmt --all --check` pass. 
Clippy reports no diagnostics in `crates/pyspark-rs/src/column.rs`.
   - Offline Python suites `tests/test_dropin_offline.py 
tests/test_ml_offline.py tests/test_arrow_handoff.py`: 2928 passed, 8 skipped, 
against the drop-in built from this change.
   - Live Python suites `tests/test_arrow_e2e.py tests/test_dropin_e2e.py 
tests/test_ml_e2e.py` against a local OSS Spark 4.3.0 Connect server: 237 
passed, 1 skipped.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5 and Claude Haiku 5.5
   
   This pull request and its description were written by Isaac.
   


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