Skip to content

[SPARK-26576][SQL] Broadcast hint not applied to partitioned table #23507

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

Closed
wants to merge 3 commits into from

Conversation

jzhuge
Copy link
Member

@jzhuge jzhuge commented Jan 10, 2019

What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

How was this patch tested?

  • A new unit test in PruneFileSourcePartitionsSuite
  • Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

@cloud-fan @davies @rxin

spark.range(10).selectExpr("id", "id % 3 as p").write.partitionBy("p").saveAsTable("tbl")

val df = spark.table("tbl")
val hints = df.join(broadcast(df), "p").queryExecution.optimizedPlan.collect {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we check the physical plan to make sure BroadcastJoin is picked?

Copy link
Contributor

@maryannxue maryannxue Jan 10, 2019

Choose a reason for hiding this comment

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

+1. And since master doesn't use ResolvedHint in optimization anymore, this issue doesn't exist in master, but figured it wouldn't hurt to add a test in master too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine with porting at least the unit test to master.

@cloud-fan
Copy link
Contributor

ok to test

@cloud-fan
Copy link
Contributor

cc @gatorsmile @maryannxue

@SparkQA
Copy link

SparkQA commented Jan 10, 2019

Test build #101013 has finished for PR 23507 at commit c3217f7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 10, 2019

Test build #101035 has finished for PR 23507 at commit dae47f1.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@@ -71,7 +71,13 @@ private[sql] object PruneFileSourcePartitions extends Rule[LogicalPlan] {
// Keep partition-pruning predicates so that they are visible in physical planning
val filterExpression = filters.reduceLeft(And)
val filter = Filter(filterExpression, prunedLogicalRelation)
Project(projects, filter)
op match {
case h: ResolvedHint =>
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tried this fix, it works. However, I am not sure about the original rational to add this code in SPARK-14581, and trying to minimize the impact of removing it because there are other callers of PhysicalOperation.unapply.

If @davies and @cloud-fan are ok and we can pass test cases covering the scenarios for this code, I'd be happy to go with this fix.

Copy link
Member

Choose a reason for hiding this comment

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

Just a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems better to remove that line.

@jzhuge
Copy link
Member Author

jzhuge commented Jan 11, 2019

Test build #101035 failures seem unrelated. VersionSuite and HiveClientSuites pass locally for me.

@SparkQA
Copy link

SparkQA commented Jan 11, 2019

Test build #101053 has finished for PR 23507 at commit 2189ce0.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Jan 11, 2019

Test build #101082 has finished for PR 23507 at commit 2189ce0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

LGTM. Thanks! Merged to 2.4 and 2.3.

asfgit pushed a commit that referenced this pull request Jan 11, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes #23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
asfgit pushed a commit that referenced this pull request Jan 11, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes #23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
(cherry picked from commit b9eb0e8)
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
@gatorsmile gatorsmile closed this Jan 11, 2019
@jzhuge
Copy link
Member Author

jzhuge commented Jan 11, 2019

Thx @gatorsmile!

Should we merge it to master any way? Remove the buggy/dead code and add a unit test.

@cloud-fan
Copy link
Contributor

The buggy code doesn't exist in master anymore, but it will be great to put the test in master. Can you send a PR to do it? thanks!

jzhuge added a commit to jzhuge/spark that referenced this pull request Jan 12, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

Closes apache#23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
(cherry picked from commit b9eb0e8)
@srowen
Copy link
Member

srowen commented Jan 13, 2019

I'm not 100% sure, but I think this is causing StreamingQuerySuite to fail consistently in 2.3, but not 2.4. See failures from https://amplab.cs.berkeley.edu/jenkins/view/Spark%20QA%20Test%20(Dashboard)/ and drill down to things like https://amplab.cs.berkeley.edu/jenkins/view/Spark%20QA%20Test%20(Dashboard)/job/spark-branch-2.3-test-maven-hadoop-2.6/577/testReport/ . Most of the subsequent build failures seem to be related to this test.

CC @maropu as this probably affects a 2.3.3 release.
@jzhuge @gatorsmile what do you think, is it an issue, and should we fix-forward or just revert from 2.3?

asfgit pushed a commit that referenced this pull request Jan 13, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

Closes #23507 from jzhuge/SPARK-26576.

Closes #23530 from jzhuge/SPARK-26576-master.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
@jzhuge
Copy link
Member Author

jzhuge commented Jan 14, 2019 via email

@maropu
Copy link
Member

maropu commented Jan 14, 2019

Sorry, but the rightest column in the page @gatorsmile showed means what? It seems StreamingOuterJoinSuite fails but the column shows pass?
Anyway, I'm not sure about why though, most of StreamingOuterJoinSuite test runs failed after this commit.... I'm running the test in branch-2.3 on my AWS env now...

@maropu
Copy link
Member

maropu commented Jan 14, 2019

I tried to run the unit tests windowed left outer join and windowed right outer join in StreamingOuterJoinSuite 3 times on my AWS env.(m4.2xlarge) though, all the runs passed....
Added cc: @tdas because these tests are related to structured streaming stuffs

@srowen
Copy link
Member

srowen commented Jan 14, 2019

It's possible it merely uncovered a different problem, in the test or main code, that only exists in 2.3.

How important is the change for 2.3? given that there is a release imminent, would it be OK to revert it now in 2.3, or does that lose an important fix?

@maropu
Copy link
Member

maropu commented Jan 15, 2019

+1 for reverting it from v2.3 (it might be worth digging into the cause though, IMO its not worth blocking the v2.3 release).
If other guys agree to that, I'll do it.

@gatorsmile
Copy link
Member

gatorsmile commented Jan 15, 2019 via email

@jzhuge
Copy link
Member Author

jzhuge commented Jan 15, 2019 via email

@maropu
Copy link
Member

maropu commented Jan 15, 2019

What I really concern about is; should we fix the StreamingOuterJoinSuite issue before the v2.3.3 release? StreamingOuterJoinSuite sometimes fails before this commit and the test seems to be originally flaky in branch-2.3 only...

@srowen
Copy link
Member

srowen commented Jan 15, 2019

That would be ideal, of course; I have no idea what the issue is or difference is with 2.4. Up to you whether you want to investigate and hold up 2.3.3, or just punt on it and revert this commit and go ahead.

@maropu
Copy link
Member

maropu commented Jan 16, 2019

ok, for now, I'll revert the commit and start the vote for the v2.3.3 release.

@maropu
Copy link
Member

maropu commented Jan 16, 2019

I reverted this commit from branch-2.3, and then added a tag for v2.3.3-rc1 in the head.
https://github.com/apache/spark/commits/branch-2.3

I'm re-publishing a candidate now, so I'll start a first vote for v2.3.3 in a few days after the Jenkins tests checked.

@gatorsmile
Copy link
Member

Thanks! @maropu

jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

Closes apache#23507 from jzhuge/SPARK-26576.

Closes apache#23530 from jzhuge/SPARK-26576-master.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
rdblue pushed a commit to rdblue/spark that referenced this pull request Apr 3, 2019
Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes apache#23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
(cherry picked from commit b9eb0e8)

Conflicts:
	sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
	sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/PruneFileSourcePartitionsSuite.scala
rdblue pushed a commit to rdblue/spark that referenced this pull request Apr 3, 2019
Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes apache#23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
(cherry picked from commit b9eb0e8)

Conflicts:
	sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
	sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/PruneFileSourcePartitionsSuite.scala
kai-chi pushed a commit to kai-chi/spark that referenced this pull request Jul 23, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes apache#23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
kai-chi pushed a commit to kai-chi/spark that referenced this pull request Aug 1, 2019
## What changes were proposed in this pull request?

Make sure broadcast hint is applied to partitioned tables.

Since the issue exists in branch 2.0 to 2.4, but not in master, I created this PR for branch-2.4.

## How was this patch tested?

- A new unit test in PruneFileSourcePartitionsSuite
- Unit test suites touched by SPARK-14581: JoinOptimizationSuite, FilterPushdownSuite, ColumnPruningSuite, and PruneFiltersSuite

cloud-fan davies rxin

Closes apache#23507 from jzhuge/SPARK-26576.

Authored-by: John Zhuge <jzhuge@apache.org>
Signed-off-by: gatorsmile <gatorsmile@gmail.com>
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.

7 participants