Skip to content

[SPARK-62507][CONNECT][PYTHON] Delegate standard term frequency and IDF feature stages to Rust - #1011

Open
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-term-weighting-rust
Open

zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-term-weighting-rust

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Route standard pyspark.ml.feature.HashingTF, CountVectorizer, CountVectorizerModel, IDF and IDFModel through the existing Rust ML bindings. Python setters update the native parameters immediately. Rust handles fitting, transformation, model properties, and persistence. Both client APIs now use the same Spark Connect helper to create a model from a supplied vocabulary.

The native feature estimator fit path honors Python subclasses' _create_model and _copyValues hooks. A fit or estimator write uses the JVM operator class selected by the Python wrapper. The shared writer also handles PySpark’s special case for PowerIterationClustering, which Spark persists through PowerIterationClusteringWrapper.

Why are the changes needed?

These standard Python imports previously constructed ML requests in Python. Reusing the Rust implementation lets the upstream PySpark feature and pipeline suites exercise the same operations used by Rust applications. SPARK-62507

Does this PR introduce any user-facing change?

The standard and compatibility imports now expose the same classes. Public members and signatures match the official PySpark 4.3.0 client. HashingTF.indexOf still requires classic PySpark. This also restores PowerIterationClustering.save, which failed on master because Spark rejects its unwrapped JVM class name.

How was this patch tested?

  • Ran the official PySpark 4.3.0 feature and pipeline parity suites against a live Connect server using this package (57 passed, four skipped).
  • Saved and loaded individual stages, fitted models, an explicit vocabulary, a pipeline, and a fitted pipeline in both directions between official PySpark and this package. Checked UIDs, explicit parameters, vocabulary ordering, document frequencies, IDF weights, sparse vector indices and values, and full output schemas. Python protobuf, gRPC and Py4J imports were blocked in the Rust-backed process.
  • Added live tests with the Python ML request builders disabled, including a subclass that selects a different JVM estimator and supplies its own model factory. Checked eager parameter updates, copying, pickling, both import paths, and mypy/Pyright compatibility.
  • Ran all 100 live standard ML tests, all 97 live feature API cases, 337 standard ML offline tests and 2,058 broader offline tests (68 skipped, four existing model-finalizer warnings). All 864 Rust library tests and 12 Rust feature tests passed. Compiled all Rust integration tests with and without wasm-udf and checked Clippy, formatting, Ruff, generated stubs and vendored source.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: OpenAI Codex (GPT-6)

This pull request and its description were written by Isaac.

…DF feature stages to Rust

Co-authored-by: Isaac <no-reply@databricks.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant