HyukjinKwon opened a new pull request, #733: URL: https://github.com/apache/spark-connect-rust/pull/733
### What changes were proposed in this pull request? This is a follow-up of SPARK-61713, found while reviewing the last 50 commits. PySpark's `ALSModel.recommendForAllUsers`, `recommendForAllItems`, `recommendForUserSubset` and `recommendForItemSubset` are decorated with `try_remote_attribute_relation`. Over Spark Connect, its wrapper takes `*args, **kwargs` and calls the server's method with the positional arguments only (`invoke_remote_attribute_relation(self, f.__name__, *args)`). So Python never checks the arity, and keyword arguments are dropped. The native methods had fixed arities, and differed from that in three ways: | call | official pyspark-client 4.3.0 | native, before | |---|---|---| | a model of no server object (`ALSModel()`), any arguments | AssertionError | TypeError for a missing or extra argument | | a fitted model, a wrong number of arguments | a DataFrame whose execution fails with `NoSuchMethodException` | TypeError at the call | | a fitted model, keyword arguments (`recommendForAllUsers(numItems=2)`) | the keywords are dropped, so the DataFrame fails with `NoSuchMethodException` | the keywords were used | This PR makes the four methods take `(*args, **kwargs)` and send the server's method with the positional arguments only, as `Word2VecModel.findSynonyms` already does. Their text signatures keep PySpark's parameter names. The native Word2Vec and LSH methods with the same decorator already matched official PySpark. ### Why are the changes needed? To match PySpark 4.3.0. ### Does this PR introduce _any_ user-facing change? Yes, the calls above now behave as in PySpark, including dropping keyword arguments. ### How was this patch tested? - New `python/tests/test_als_recommendation_arguments_e2e.py`, live: the unbound AssertionError for every arity, the DataFrames of a wrong arity and of keyword arguments failing with `NoSuchMethodException` at execution, and the right call. All 12 tests fail without the change, and pass on this client and on official PySpark 4.3.0 as the reference. It is added to the drop-in live-server step of `build_python_connect.yml`. - `test_als_offline.py` called these methods with keyword arguments, which PySpark drops. Its two tests now call them positionally, as `scripts/capture_als_golden.py` does, and assert that a call of keyword arguments sends none. - On this client, the ALS, fpm/recommendation and ML API suites pass, offline and live, and so does the CI-order offline suite. - `cargo fmt --check`, `cargo +1.100.0 clippy --workspace --all-targets -- -D warnings`, `scripts/audit_no_stubs.sh`, `ruff check` and `ruff format --check` are clean. ### 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]
