Skip to content
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

[GLUTEN-3486][CH] Fix AQE cannot coalesce shuffle partitions #3941

Merged
merged 3 commits into from
Dec 8, 2023

Conversation

exmy
Copy link
Contributor

@exmy exmy commented Dec 6, 2023

What changes were proposed in this pull request?

When there are non-field expressions in shuffle hash expression, we add a pre-project before shuffle exchange operator and change shuffle hash expression to field expression projected_partitioning_value which prevents AQE's CoalesceShufflePartitions and OptimizeSkewedJoin rules from being effective. This pr introduces a HashPartitioningWrapper in order to remain original shuffle hash expressions.

(Fixes: #3486)

How was this patch tested?

manual tests

Copy link

github-actions bot commented Dec 6, 2023

#3486

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

@lgbo-ustc
Copy link
Contributor

LGTM

@zzcclp zzcclp requested review from rui-mo and ulysses-you December 6, 2023 08:25
import org.apache.spark.sql.catalyst.expressions.Expression
import org.apache.spark.sql.catalyst.plans.physical.HashPartitioning

class HashPartitioningWrapper(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add some description for the functionality of this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -20,6 +20,7 @@ import io.glutenproject.GlutenConfig
import io.glutenproject.backendsapi.BackendsApiManager
import io.glutenproject.execution._
import io.glutenproject.extension.{GlutenPlan, ValidationResult}
import io.glutenproject.sql.shims.SparkShimLoader
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop this change?

@rui-mo rui-mo requested a review from PHILO-HE December 6, 2023 09:02
(projectExpressions.size, HashPartitioning(newExprs, numPartitions), project)
(
projectExpressions.size,
new HashPartitioningWrapper(exprs, newExprs, numPartitions),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I get it. AQE won't touch the expressions in hash partitioning, then how can it affect AQE behavior ? Does it also affect range partitioning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, and these codes only be used in ch backend so Velox backend does not have this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks reasonable to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, and these codes only be used in ch backend so Velox backend does not have this issue.

yes

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

Copy link

github-actions bot commented Dec 6, 2023

Run Gluten Clickhouse CI

Copy link
Contributor

@PHILO-HE PHILO-HE left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks!

@zzcclp zzcclp merged commit 2ccea31 into apache:main Dec 8, 2023
17 checks passed
@GlutenPerfBot
Copy link
Contributor

===== Performance report for TPCH SF2000 with Velox backend, for reference only ====

query log/native_3941_time.csv log/native_master_12_07_2023_9c5314fd5_time.csv difference percentage
q1 36.16 33.97 -2.192 93.94%
q2 24.90 24.95 0.043 100.17%
q3 38.27 37.91 -0.361 99.06%
q4 35.63 37.39 1.765 104.95%
q5 73.13 71.30 -1.829 97.50%
q6 6.80 5.38 -1.425 79.06%
q7 84.07 85.81 1.746 102.08%
q8 84.72 85.80 1.081 101.28%
q9 128.06 123.51 -4.553 96.44%
q10 44.65 45.87 1.213 102.72%
q11 20.43 20.29 -0.143 99.30%
q12 27.20 26.73 -0.469 98.28%
q13 46.28 45.73 -0.552 98.81%
q14 15.28 16.69 1.412 109.24%
q15 28.85 28.46 -0.384 98.67%
q16 16.84 15.56 -1.287 92.36%
q17 101.28 103.37 2.094 102.07%
q18 148.55 149.01 0.462 100.31%
q19 14.10 12.84 -1.252 91.12%
q20 27.58 27.78 0.199 100.72%
q21 226.54 223.73 -2.807 98.76%
q22 13.30 13.39 0.090 100.67%
total 1242.62 1235.47 -7.149 99.42%

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.

[CH] AQE cannot coalesce partitions when Exchange hash partitioning exists non-attribute expressions
7 participants