Skip to content

[SPARK-58964][ML] Consolidate vector and matrix UDT column conversion - #58241

Open
zhengruifeng wants to merge 7 commits into
apache:masterfrom
zhengruifeng:ml-consolidate-matrix-udt-conversion-dev-3
Open

[SPARK-58964][ML] Consolidate vector and matrix UDT column conversion#58241
zhengruifeng wants to merge 7 commits into
apache:masterfrom
zhengruifeng:ml-consolidate-matrix-udt-conversion-dev-3

Conversation

@zhengruifeng

@zhengruifeng zhengruifeng commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR consolidates UDT column selection in these MLUtils conversion helpers:

  • MLUtils.convertVectorColumnsToML
  • MLUtils.convertVectorColumnsFromML
  • MLUtils.convertMatrixColumnsToML
  • MLUtils.convertMatrixColumnsFromML

When columns are not explicitly specified, each helper preserves the previous automatic selection
behavior: ToML helpers select only old mllib UDT columns, and FromML helpers select only new
ml UDT columns. For explicit columns, the helpers validate that the named columns exist and rely
on the existing wrap_udt(unwrap_udt(...)) expression analysis to reject non-UDT inputs.
Converted columns are replaced with the metadata-preserving withColumns overload instead of
rebuilding the whole projection manually.

Why are the changes needed?

After vector and matrix conversion moved to wrap_udt / unwrap_udt, the explicit-column paths no
longer need separate source-type and target-type branches when deciding whether a column can be
converted.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Ran:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 build/sbt 'mllib/testOnly org.apache.spark.mllib.util.MLUtilsSuite -- -z "convertVectorColumnsToML" -z "convertVectorColumnsFromML" -z "convert nullable vector columns" -z "convertMatrixColumnsToML" -z "convertMatrixColumnsFromML" -z "convert nullable matrix columns"'

Also ran:

  • git diff --check
  • line-length scan for the changed Scala files
  • non-ASCII scan for the changed Scala files

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

Generated-by: OpenAI Codex

@zhengruifeng zhengruifeng changed the title [SPARK-58964][ML] Consolidate matrix UDT column conversion [SPARK-58964][ML] Consolidate vector and matrix UDT column conversion Aug 24, 2026
@zhengruifeng
zhengruifeng marked this pull request as draft August 24, 2026 09:23
@zhengruifeng
zhengruifeng marked this pull request as ready for review August 24, 2026 12:23
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