[SPARK-36458][ML] Allow approxSimilarityJoin and approxNearestNeighbors to work without inputCol#55854
Open
Phucvt123 wants to merge 1 commit into
Open
[SPARK-36458][ML] Allow approxSimilarityJoin and approxNearestNeighbors to work without inputCol#55854Phucvt123 wants to merge 1 commit into
Phucvt123 wants to merge 1 commit into
Conversation
…rs to work without inputCol ## What changes were proposed in this pull request? Modified LSHModel to conditionally check for the existence of inputCol in approxSimilarityJoin and approxNearestNeighbors. When inputCol is missing (user already transformed and dropped it), the methods now fall back to hash-based approximate distance using outputCol instead of throwing an error. ## Why are the changes needed? Users who pre-compute hashes and drop the original features column to save memory/storage cannot use approxSimilarityJoin or approxNearestNeighbors. The documentation implies this should work but the current implementation always requires inputCol. ## Does this PR introduce any user-facing change? Yes. approxSimilarityJoin and approxNearestNeighbors now accept datasets that contain only the outputCol (hashes) without inputCol. When inputCol is present, behavior is unchanged (exact distance). When inputCol is absent, hash-based approximate distance is used. ## How was this patch tested? Added 3 unit tests in MinHashLSHSuite: - approxSimilarityJoin without inputCol - approxNearestNeighbors without inputCol - approxSimilarityJoin self-join without inputCol All existing tests continue to pass. Closes #SPARK-36458
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?
Modified
LSHModelto conditionally check for the existence ofinputColinapproxSimilarityJoinandapproxNearestNeighbors. WheninputColis missing (user already transformed and dropped it), the methods now fall back to hash-based approximate distance usingoutputColinstead of throwing an error.Why are the changes needed?
Users who pre-compute hashes and drop the original features column to save memory/storage cannot use
approxSimilarityJoinorapproxNearestNeighbors. The documentation implies this should work, but the current implementation always requiresinputCol.Does this PR introduce any user-facing change?
Yes.
approxSimilarityJoinandapproxNearestNeighborsnow accept datasets that contain only theoutputCol(hashes) withoutinputCol. WheninputColis present, behavior is unchanged (exact distance). WheninputColis absent, hash-based approximate distance is used with a warning logged.How was this patch tested?
Added 3 unit tests in
MinHashLSHSuite:approxSimilarityJoinwithoutinputColapproxNearestNeighborswithoutinputColapproxSimilarityJoinself-join withoutinputColAll 17 tests pass (14 existing + 3 new).
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Anthropic Claude Opus 4.6)