Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ class InMemoryTable(
throw new IllegalArgumentException(s"Match: unsupported argument(s) type - ($v, $t)")
}
case BucketTransform(numBuckets, ref) =>
(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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine. One common hashCode pattern is a + 31 * b, in the JVM source, FWIW.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, @srowen . I'll update like that.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,7 @@ class DataSourceV2SQLSuite

checkAnswer(
spark.sql(s"SELECT id, data, _partition FROM $t1"),
Seq(Row(1, "a", "3/1"), Row(2, "b", "2/2"), Row(3, "c", "2/3")))
Seq(Row(1, "a", "3/1"), Row(2, "b", "0/2"), Row(3, "c", "1/3")))
}
}

Expand All @@ -2524,7 +2524,7 @@ class DataSourceV2SQLSuite

checkAnswer(
spark.sql(s"SELECT index, data, _partition FROM $t1"),
Seq(Row(3, "c", "2/3"), Row(2, "b", "2/2"), Row(1, "a", "3/1")))
Seq(Row(3, "c", "1/3"), Row(2, "b", "0/2"), Row(1, "a", "3/1")))
}
}

Expand Down