Repository navigation
[SPARK-62501][CONNECT][PYTHON] Delegate standard FPGrowth operations to Rust - #1005
Closed
zhengruifeng wants to merge 1 commit into
Closed
zhengruifeng wants to merge 1 commit into
zhengruifeng wants to merge 1 commit into
Conversation
…to Rust Co-authored-by: Isaac <no-reply@databricks.com>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Route
pyspark.ml.fpm.FPGrowthandFPGrowthModelthrough the existing Rust ML implementation. Python setters update native parameters eagerly. Rust fits the model, builds the transform and the lazyfreqItemsetsandassociationRulesDataFrames, 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 resultingRemoteModelRefto 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.pyand publishes the two Rust-backed classes. The compatibility import aliases the same classes. StandardPrefixSpancontinues 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?
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.