-
Notifications
You must be signed in to change notification settings - Fork 28k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-48000][SQL] Enable hash join support for all collations (StringType) #46599
Conversation
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CollationKey.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteCollationJoin.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/CollationKey.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM + a couple of ~minor comments.
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteCollationJoin.scala
Outdated
Show resolved
Hide resolved
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteCollationJoin.scala
Outdated
Show resolved
Hide resolved
@@ -250,7 +250,8 @@ abstract class Optimizer(catalogManager: CatalogManager) | |||
InsertMapSortInGroupingExpressions) :+ | |||
// This batch must be executed after the `RewriteSubquery` batch, which creates joins. | |||
Batch("NormalizeFloatingNumbers", Once, NormalizeFloatingNumbers) :+ | |||
Batch("ReplaceUpdateFieldsExpression", Once, ReplaceUpdateFieldsExpression) | |||
Batch("ReplaceUpdateFieldsExpression", Once, ReplaceUpdateFieldsExpression) :+ | |||
Batch("RewriteCollationJoin", Once, RewriteCollationJoin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this enlarges the query plan (adding CollationKey
), we should do it as late as possible: the last rule in SparkOptimizer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved RewriteCollationJoin
to SparkOptimizer.postHocOptimizationBatches
(I think this would be the last possible place)
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/CollationSuite.scala
Outdated
Show resolved
Hide resolved
@uros-db unfortunately it has merge conflicts now... |
thanks, merging to master! |
What changes were proposed in this pull request?
Enable collation support for hash join on StringType. Note: support for complex types will be added separately.
CollationKey
CollationKey
is a unary expression that transformsStringType
toBinaryType
Why are the changes needed?
Improve JOIN performance for collated strings.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
CollationKey
inCollationExpressionSuite
RewriteCollationJoin
inCollationSuite
Was this patch authored or co-authored using generative AI tooling?
No.