-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-44897][SQL] Propagating local properties to subquery broadcast exec #42587
[SPARK-44897][SQL] Propagating local properties to subquery broadcast exec #42587
Conversation
72c3b5f
to
cb71086
Compare
cb71086
to
62b940c
Compare
cc @cloud-fan, @maropu |
@@ -191,6 +191,52 @@ class ExecutorSideSQLConfSuite extends SparkFunSuite with SQLTestUtils { | |||
assert(checks2.forall(_.toSeq == Seq(true, true))) | |||
} | |||
} | |||
|
|||
test("SPARK-44897 propagate local properties to subquery broadcast execuction thread") { |
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.
if this test can't reproduce the bug directly, we can put it in the PR descriptions with instructions about the extra change to reproduce the bug (add sleep).
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.
Ok. Does it make sense to leave this test in the code still or do you think putting it in the description with instructions is enough
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.
Please remove the test case from the code, @ChenMichael . PR description (with your reproducible instruction is enough).
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.
👍 Done
thanks, merging to master/3.5! |
… exec ### What changes were proposed in this pull request? https://issues.apache.org/jira/browse/SPARK-32748 previously proposed propagating these local properties to the subquery broadcast exec threads but was then reverted since it was said that local properties would already be propagated to the broadcast threads. I believe this is not always true. In the scenario where a separate `BroadcastExchangeExec` is the first to compute the broadcast, this is fine. However, in the scenario where the `SubqueryBroadcastExec` is the first to compute the broadcast, then the local properties that are propagated to the broadcast threads would not have been propagated correctly. This is because the local properties from the subquery broadcast exec were not propagated to its Future thread. It is difficult to write a unit test that reproduces this behavior because usually `BroadcastExchangeExec` is the first computing the broadcast variable. However, by adding a `Thread.sleep(10)` to `SubqueryBroadcastExec.doPrepare` after `relationFuture` is initialized, the added test will consistently fail. ### Why are the changes needed? Local properties are not propagated correctly to `SubqueryBroadcastExec` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Following test can reproduce the bug and test the solution by adding sleep to `SubqueryBroadcastExec.doPrepare` ``` protected override def doPrepare(): Unit = { relationFuture Thread.sleep(10) } ``` ```test("SPARK-44897 propagate local properties to subquery broadcast execuction thread") { withSQLConf(StaticSQLConf.BROADCAST_EXCHANGE_MAX_THREAD_THRESHOLD.key -> "1") { withTable("a", "b") { val confKey = "spark.sql.y" val confValue1 = UUID.randomUUID().toString() val confValue2 = UUID.randomUUID().toString() Seq((confValue1, "1")).toDF("key", "value") .write .format("parquet") .partitionBy("key") .mode("overwrite") .saveAsTable("a") val df1 = spark.table("a") def generateBroadcastDataFrame(confKey: String, confValue: String): Dataset[String] = { val df = spark.range(1).mapPartitions { _ => Iterator(TaskContext.get.getLocalProperty(confKey)) }.filter($"value".contains(confValue)).as("c") df.hint("broadcast") } // set local property and assert val df2 = generateBroadcastDataFrame(confKey, confValue1) spark.sparkContext.setLocalProperty(confKey, confValue1) val checkDF = df1.join(df2).where($"a.key" === $"c.value").select($"a.key", $"c.value") val checks = checkDF.collect() assert(checks.forall(_.toSeq == Seq(confValue1, confValue1))) // change local property and re-assert Seq((confValue2, "1")).toDF("key", "value") .write .format("parquet") .partitionBy("key") .mode("overwrite") .saveAsTable("b") val df3 = spark.table("b") val df4 = generateBroadcastDataFrame(confKey, confValue2) spark.sparkContext.setLocalProperty(confKey, confValue2) val checks2DF = df3.join(df4).where($"b.key" === $"c.value").select($"b.key", $"c.value") val checks2 = checks2DF.collect() assert(checks2.forall(_.toSeq == Seq(confValue2, confValue2))) assert(checks2.nonEmpty) } } } ``` ### Was this patch authored or co-authored using generative AI tooling? No Closes #42587 from ChenMichael/SPARK-44897-local-property-propagation-to-subquery-broadcast-exec. Authored-by: Michael Chen <mike.chen@workday.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 4a48562) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
https://issues.apache.org/jira/browse/SPARK-32748 previously proposed propagating these local properties to the subquery broadcast exec threads but was then reverted since it was said that local properties would already be propagated to the broadcast threads.
I believe this is not always true. In the scenario where a separate
BroadcastExchangeExec
is the first to compute the broadcast, this is fine. However, in the scenario where theSubqueryBroadcastExec
is the first to compute the broadcast, then the local properties that are propagated to the broadcast threads would not have been propagated correctly. This is because the local properties from the subquery broadcast exec were not propagated to its Future thread.It is difficult to write a unit test that reproduces this behavior because usually
BroadcastExchangeExec
is the first computing the broadcast variable. However, by adding aThread.sleep(10)
toSubqueryBroadcastExec.doPrepare
afterrelationFuture
is initialized, the added test will consistently fail.Why are the changes needed?
Local properties are not propagated correctly to
SubqueryBroadcastExec
Does this PR introduce any user-facing change?
No
How was this patch tested?
Following test can reproduce the bug and test the solution by adding sleep to
SubqueryBroadcastExec.doPrepare
Was this patch authored or co-authored using generative AI tooling?
No