Uh oh!
There was an error while loading. Please reload this page.
[SPARK-33524][SQL][TESTS] Change InMemoryTable not to use Tuple.hashCode for BucketTransform - #30477
Closed
dongjoon-hyun wants to merge 2 commits into
Closed
[SPARK-33524][SQL][TESTS] Change InMemoryTable not to use Tuple.hashCode for BucketTransform#30477dongjoon-hyun wants to merge 2 commits into
InMemoryTable not to use Tuple.hashCode for BucketTransform#30477dongjoon-hyun wants to merge 2 commits into
Conversation
BucketTransform not to use Tuple.hashCode.rdblue
approved these changes
Nov 24, 2020
rdblue
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me. Thanks for tracking this down, @dongjoon-hyun!
dongjoon-hyun
commented
Nov 24, 2020
MemberAuthor
Thank you, @rdblue ! |
BucketTransform not to use Tuple.hashCode.BucketTransform not to use Tuple.hashCode.BucketTransform not to use Tuple.hashCode.InMemoryTable not to use Tuple.hashCode for BucketTransformHyukjinKwon
approved these changes
Nov 24, 2020
srowen
reviewed
Nov 24, 2020
| (extractor(ref.fieldNames, schema, row).hashCode() & Integer.MAX_VALUE) % numBuckets | ||
| val (value, dataType) = extractor(ref.fieldNames, schema, row) | ||
| val valueHashCode = if (value == null) 0 else value.hashCode | ||
| ((valueHashCode + dataType.hashCode()) & Integer.MAX_VALUE) % numBuckets |
Member
There was a problem hiding this comment.
Seems fine. One common hashCode pattern is a + 31 * b, in the JVM source, FWIW.
SparkQA
commented
Nov 24, 2020
Test build #131576 has finished for PR 30477 at commit
|
dongjoon-hyun
commented
Nov 24, 2020
MemberAuthor
The last change affects only |
dongjoon-hyun
commented
Nov 24, 2020
MemberAuthor
I'll merge this. Thank you, @rdblue , @HyukjinKwon , @srowen . |
dongjoon-hyun added a commit
that referenced
this pull request
Nov 24, 2020
…hCode for `BucketTransform` This PR aims to change `InMemoryTable` not to use `Tuple.hashCode` for `BucketTransform`. SPARK-32168 made `InMemoryTable` to handle `BucketTransform` as a hash of `Tuple` which is dependents on Scala versions. - https://github.com/apache/spark/blob/master/sql/catalyst/src/test/scala/org/apache/spark/sql/connector/InMemoryTable.scala#L159 **Scala 2.12.10** ```scala $ bin/scala Welcome to Scala 2.12.10 (OpenJDK 64-Bit Server VM, Java 1.8.0_272). Type in expressions for evaluation. Or try :help. scala> (1, 1).hashCode res0: Int = -2074071657 ``` **Scala 2.13.3** ```scala Welcome to Scala 2.13.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_272). Type in expressions for evaluation. Or try :help. scala> (1, 1).hashCode val res0: Int = -1669302457 ``` Yes. This is a correctness issue. Pass the UT with both Scala 2.12/2.13. Closes#30477 from dongjoon-hyun/SPARK-33524. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org> (cherry picked from commit 8380e00) Signed-off-by: Dongjoon Hyun <dongjoon@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 freeto 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?
This PR aims to change
InMemoryTablenot to useTuple.hashCodeforBucketTransform.Why are the changes needed?
SPARK-32168 made
InMemoryTableto handleBucketTransformas a hash ofTuplewhich is dependents on Scala versions.Scala 2.12.10
Scala 2.13.3
Does this PR introduce any user-facing change?
Yes. This is a correctness issue.
How was this patch tested?
Pass the UT with both Scala 2.12/2.13.