-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33612][SQL] Add dataSourceRewriteRules batch to Optimizer #30558
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
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,9 @@ abstract class BaseSessionStateBuilder( | |
| override def earlyScanPushDownRules: Seq[Rule[LogicalPlan]] = | ||
| super.earlyScanPushDownRules ++ customEarlyScanPushDownRules | ||
|
|
||
| override def dataSourceRewriteRules: Seq[Rule[LogicalPlan]] = | ||
| super.dataSourceRewriteRules ++ customDataSourceRewriteRules | ||
|
|
||
| override def extendedOperatorOptimizationRules: Seq[Rule[LogicalPlan]] = | ||
| super.extendedOperatorOptimizationRules ++ customOperatorOptimizationRules | ||
| } | ||
|
|
@@ -263,6 +266,14 @@ abstract class BaseSessionStateBuilder( | |
| */ | ||
| protected def customEarlyScanPushDownRules: Seq[Rule[LogicalPlan]] = Nil | ||
|
|
||
| /** | ||
| * Custom rules for rewriting data source plans to add to the Optimizer. Prefer overriding | ||
| * this instead of creating your own Optimizer. | ||
| * | ||
| * Note that this may NOT depend on the `optimizer` function. | ||
| */ | ||
| protected def customDataSourceRewriteRules: Seq[Rule[LogicalPlan]] = Nil | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name does not explain the goal. IMO, this is misleading. Let us make the API name more general. It is not related to the data sources. |
||
|
|
||
| /** | ||
| * Planner that converts optimized logical plans to physical plans. | ||
| * | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Basically, what you want to do is to add an extension point/batch between heuristics-based optimizer and cost-based optimizer.
The batch name and comments look not good to me. We need a better name here.
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.
cc @maryannxue @hvanhovell
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.
Could you propose a name then, @gatorsmile ?
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.
I am open to alternatives.
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.
We should probably combine this batch with the one below:
earlyScanPushDownRules, and give it a more general name similar toextendedOperatorOptimizationRules.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.
I'd vote for
preCBORules.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.
According to the current discussion, could you make a follow-up PR with
preCBORules, @aokolnychyi ? If we have a PR, it would be easier to make a final decision.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.
I don't think that
preCBORulesis a good name. This batch is for rewrites that need to happen after basic optimization simplifies expressions and then pushes filters and projections. It also needs to happen before early pushdown, which in turn needs to come before CBO. All of that is before CBO, and that name doesn't capture what this is to be used for.A more descriptive name is "planRewriteRules" because this is for rewriting plans after initial optimization, but before other optimizer rules that need to run after that rewrite, like early pushdown, CBO, etc.
The name "postOperatorOptimizationRules" is okay, but not very descriptive.
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.
Let's finish this discussion in a separate PR. I'll create one now.
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.
I created PR #30808