Skip to content

[SPARK-62499][CONNECT][PYTHON] Delegate standard PowerIterationClustering operations to Rust - #1004

Closed
zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-power-iteration-rust
Closed

zhengruifeng wants to merge 1 commit into
apache:masterfrom
zhengruifeng:feature/standard-power-iteration-rust

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Delegate pyspark.ml.clustering.PowerIterationClustering.assignClusters and persistence to the Rust ML implementation. The compatibility import re-exports the standard class. Parameter setters update the native object immediately.

The Python binding calls the public parameter getters when building the assignment, including subclass overrides and custom defaults. It then passes the input and the resolved arguments to the same Rust relation builder as PowerIterationClustering::assign_clusters. The returned DataFrame captures the graph and parameter values at the time of the call.

Why are the changes needed?

Power iteration clustering is the last of the five standard clustering algorithms whose Python entry point still built its own Spark Connect requests. Sharing the assignment relation lets the official PySpark clustering tests exercise the protocol used by Rust callers. SPARK-62499

Does this PR introduce any user-facing change?

Existing callers continue to use assignClusters(dataset), which returns a DataFrame with id and cluster. The standard and compatibility imports now refer to the same class. Its constructor and all 37 public members match PySpark 4.3.0. This change adds no Python dependencies.

How was this patch tested?

  • Ran the standard API against a local Spark 4.3.0 Connect server with the Python ML request builders disabled. The same six-vertex graph produces one group without weights and two groups with weights. The test checks vertex membership, the result schema, lazy parameter capture and persistence.
  • Saved weighted and unweighted algorithms with official PySpark, loaded them with the Rust-backed client and compared their UIDs and assignments. Repeated in the other direction with the same results.
  • Compared the lazy helper requests with official protobuf fixtures. Covered custom defaults, a subclass overriding getK, an omitted or explicit null weight column, and deferred overflow errors.
  • Ran the upstream clustering, model offloading, cache, pipeline and tuning suites in drop-in mode (31 passed, 4 skipped), the offline ML and type-stub suites, the Rust library and clustering tests, full integration-test compilation with and without wasm-udf, Clippy, Ruff, formatting, and the generated-file and vendor checks.

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.

…ring operations to Rust

Co-authored-by: Isaac <no-reply@databricks.com>
@zhengruifeng
zhengruifeng deleted the feature/standard-power-iteration-rust branch December 1, 2026 07:59
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