Skip to content

[SPARK-62501][CONNECT][PYTHON] Delegate standard FPGrowth operations to Rust - #1005

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

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

Conversation

@zhengruifeng

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Route pyspark.ml.fpm.FPGrowth and FPGrowthModel through the existing Rust ML implementation. Python setters update native parameters eagerly. Rust fits the model, builds the transform and the lazy freqItemsets and associationRules DataFrames, and handles estimator and model persistence.

A Python subclass can still override _fit, _create_model, or _copyValues. When a subclass supplies its own model factory, Rust fits the estimator and passes the resulting RemoteModelRef to that factory. The custom model then owns the reference and uses the usual PySpark cleanup.

The public module loads Spark 4.3.0’s definitions from the byte-identical _upstream/fpm.py and publishes the two Rust-backed classes. The compatibility import aliases the same classes. Standard PrefixSpan continues to use its upstream implementation.

Why are the changes needed?

The standard Python API and the Rust client each constructed FPGrowth requests. Sharing the Rust implementation lets upstream PySpark FPGrowth tests exercise the same fit, transform and persistence operations that Rust callers use. SPARK-62501

Does this PR introduce any user-facing change?

The import paths, public method signatures, and saved model format are preserved. This change adds no Python dependency.

How was this patch tested?

  • Ran the new live FPGrowth tests against Spark Connect with Python ML request builders disabled and unraisable warnings treated as errors. Both passed, including collecting lazy results after dropping the model. Another 21 live frequent-pattern checks passed.
  • Ran five upstream PySpark test modules against the drop-in client, covering FPM, model offloading, cache handling, pipelines and tuning. 27 tests passed and four were skipped.
  • Saved and loaded models in both directions between official PySpark 4.3.0 and the Rust-backed client. Itemsets, association rules, predictions and loaded schemas matched on string baskets, integer baskets, and a case with no qualifying rules.
  • 1,348 offline Python checks passed (68 skipped). All 864 Rust library tests and eight focused Rust frequent-pattern, golden, and replay tests passed. All Rust integration tests compiled with and without wasm-udf. Checked formatting, Clippy, public signatures, 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.

…to Rust

Co-authored-by: Isaac <no-reply@databricks.com>
@zhengruifeng
zhengruifeng deleted the feature/standard-fpgrowth-rust branch December 1, 2026 09:03
zhengruifeng added a commit that referenced this pull request Dec 1, 2026
…s to Rust

### What changes were proposed in this pull request?

Route standard `pyspark.ml.fpm.PrefixSpan.findFrequentSequentialPatterns` through the Rust helper used by `ml::PrefixSpan`. Both clients build the same lazy Connect relation and retain its input DataFrame. The compatibility import exposes the same Python class.

The four Python parameters update native state eagerly. When building the relation, the binding calls the Python getters in PySpark order, so subclasses can override them. Copies and pickle round trips preserve custom defaults.

### Why are the changes needed?

Standard PySpark, the native Python binding and the Rust API previously built the PrefixSpan request separately. Sharing the Rust implementation means the upstream PySpark test exercises the relation that Rust callers use. This completes the standard frequent-pattern API migration following #1005. [SPARK-62502](https://issues.apache.org/jira/browse/SPARK-62502)

### Does this PR introduce _any_ user-facing change?

The existing Python import paths and signatures are preserved. `findFrequentSequentialPatterns` continues to return a lazy DataFrame with `sequence` and `freq` columns. This change adds no Python dependency.

### How was this patch tested?

- Ran all 14 tests from the upstream PySpark FPM, model offloading and cache modules against the drop-in client.
- Ran 22 live Python checks, including a subclass overriding a getter with the Python helper disabled. A separate comparison against official PySpark 4.3.0 matched rows and exact schemas for integer sequences with a null row, string sequences, and an input with no qualifying patterns.
- Compared the constructor and all 27 public PrefixSpan members with official PySpark. Ran the 308 standard ML offline tests, the broader ML offline suite (2,032 passed, 68 skipped), and the type-stub checks.
- All 864 Rust library tests and eight focused mining, golden and replay tests passed. Compiled all integration tests with and without `wasm-udf`. Checked Rust formatting, Clippy, Ruff, generated stubs and vendored-source drift.

### 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.

Closes #1006 from zhengruifeng/feature/standard-prefixspan-rust.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
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