HyukjinKwon opened a new pull request, #658:
URL: https://github.com/apache/spark-connect-rust/pull/658
### What changes were proposed in this pull request?
A follow-up of #647 (SPARK-61639). The native `ALSModel` took a Column of a
literal, such as `F.lit(1)`, as the count of `recommendForAllUsers`,
`recommendForAllItems`, `recommendForUserSubset` and `recommendForItemSubset`,
and recommended that many. PySpark serializes the count with
`LiteralExpression._from_value`, which takes no Column. With this PR, a Column
count raises PySpark's `PySparkTypeError` `UNSUPPORTED_DATA_TYPE` of `Column`
before any request, as the drop-in already did for `F.col("user")`.
### Why are the changes needed?
For parity with `pyspark.ml` over Spark Connect in 4.3.0. A post-merge
review of #647 found the gap.
- Before: `model.recommendForAllUsers(F.lit(1)).count()` returned 3.
- After, as PySpark 4.3.0, for each of the four methods and for both
`F.lit(1)` and `F.col("user")`: `PySparkTypeError` with `UNSUPPORTED_DATA_TYPE`
and `{'data_type': 'Column'}`, checked against PySpark on a Spark 4.3.0 server.
### Does this PR introduce _any_ user-facing change?
Yes. A Column count of the ALS recommendations raises PySpark's error, as in
PySpark.
### How was this patch tested?
- A new offline test,
`test_a_column_count_fails_before_requests_as_pyspark`, calls each of the four
methods with `F.lit(1)` and `F.col("user")`. It fails without the fix (`DID NOT
RAISE PySparkTypeError`).
- Also passing, with `TZ=UTC`:
- `test_als_e2e.py` against Spark 4.3.0: 11 passed;
- the offline Python set, including the ML, frequent-pattern and ALS
offline files: 4443 passed;
- `cargo fmt`, the stub audit and ruff.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 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]