Skip to content

Conversation

@ulysses-you
Copy link
Contributor

@ulysses-you ulysses-you commented Jun 5, 2023

What changes were proposed in this pull request?

#41046 make ReuseAdaptiveSubquery become not idempotent. This pr reverts the change in ReuseAdaptiveSubquery.

To solve the same instance issue when planning and reusing subquery in AQE, this pr makes subqueryMap hold the executed plan in subquery. Then in PlanAdaptiveSubqueries, each logical subquery plan can build their own instance of physical subquery.

Why are the changes needed?

To improve reuse subquery in AQE.

Does this PR introduce any user-facing change?

no

How was this patch tested?

Pass CI

@github-actions github-actions bot added the SQL label Jun 5, 2023
@ulysses-you
Copy link
Contributor Author

cc @cloud-fan @maryannxue

val subquery = SubqueryExec.createForScalarSubquery(
s"subquery#${exprId.id}", executedPlan)
subqueryMap.put(exprId.id, subquery)
subqueryMap.put(exprId.id, executedPlan)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems now all subqueries have the same handling code, can we just match the logical subqueries here and build the map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeas, cleaned up these code

name, broadcastKeyIndex, onlyInBroadcast,
buildPlan, buildKeys, executedPlan)
subqueryMap.put(exprId.id, subquery)
case subquery: SubqueryExpression if !subqueryMap.contains(subquery.exprId.id) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

to be conservative, how about case subquery @ (_: ScalarSubquery | _: InSubquery | _: DynamicPruningSubquery) => ...

@ulysses-you
Copy link
Contributor Author

@cloud-fan the failed test seems irrelevant

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 41fd030 Jun 7, 2023
@ulysses-you ulysses-you deleted the SPARK-43376-2 branch June 8, 2023 01:35
czxm pushed a commit to czxm/spark that referenced this pull request Jun 12, 2023
… subquery

### What changes were proposed in this pull request?

apache#41046 make `ReuseAdaptiveSubquery` become not idempotent. This pr reverts the change in `ReuseAdaptiveSubquery`.

To solve the same instance issue when planning and reusing subquery in AQE, this pr makes `subqueryMap` hold the executed plan in subquery. Then in `PlanAdaptiveSubqueries`, each logical subquery plan can build their own instance of physical subquery.

### Why are the changes needed?

To improve reuse subquery in AQE.

### Does this PR introduce _any_ user-facing change?

no

### How was this patch tested?

Pass CI

Closes apache#41454 from ulysses-you/SPARK-43376-2.

Authored-by: ulysses-you <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants