HyukjinKwon opened a new pull request, #666:
URL: https://github.com/apache/spark-connect-rust/pull/666
### What changes were proposed in this pull request?
A follow-up to #639 from its post-merge review. Over Spark Connect,
PySpark's `StopWordsRemover.loadDefaultStopWords(language)` reads the server's
default stop words through the ML helper, with
`invoke_helper_attr("stopWordsRemoverLoadDefaultStopWords", language)`. It's
commonly used to extend the default list. The native `StopWordsRemover` had no
such method, so it raised `AttributeError`.
- **Rust:**
- `ml_helper_attribute(session, method, args)` runs a `Fetch` of the ML
helper as an ML command, as `invoke_helper_attr` does, and returns the result
literal.
- `StopWordsRemover::load_default_stop_words(session, language)` is built
on top of it.
- **Python:** `StopWordsRemover.loadDefaultStopWords(language)` calls the
helper on the active session.
- Without an active session it raises PySpark's bare `AssertionError`.
- It sends the language as the literal of its value, as PySpark's
`serialize` does. So a value with no literal raises `UNSUPPORTED_DATA_TYPE`
before any request, and the server rejects the others, such as `None`, `5` or
an unknown language, with the same errors as for PySpark.
- `feature_wrapper!` takes the extra method.
### Why are the changes needed?
So that the native class has PySpark's method.
### Does this PR introduce _any_ user-facing change?
Yes. `StopWordsRemover.loadDefaultStopWords` is available on the native
class.
### How was this patch tested?
- Against a Spark 4.3.0 Connect server, it gives the same results and errors
as the official `pyspark-client` 4.3.0 in all 9 cases checked: no session,
after `stop()`, `"english"`, `language="french"`, `None`, `5`, `object()`,
`"German"`, and no argument.
- A new live test in `test_ml_features_e2e.py` covers the English and French
lists, a remover that extends the defaults, and the error of an unknown
language. It passes on this client and unchanged on the official client
(`FEATURE_REFERENCE=1`). The file passed 112 tests.
- New offline tests check the exact `Fetch` sent and the parsing of its
result, `UNSUPPORTED_DATA_TYPE` before any request, and the `AssertionError`
without an active session. `test_ml_features_offline.py` and
`test_ml_offline.py` passed 976 tests.
- Rust: a live test of `load_default_stop_words` and a unit test of the
array parsing. `e2e_ml_features` passed 2. Clippy and fmt 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]