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

[Enhancement] Prune group bys and eliminate aggs by UK and FK #52201

Merged
merged 8 commits into from
Nov 5, 2024

Conversation

ZiheLiu
Copy link
Contributor

@ZiheLiu ZiheLiu commented Oct 22, 2024

Why I'm doing:

To enhance table pruning and aggregation elimination for more scenarios, introduce the following two rules under the enable_ukfk_opt feature:

  1. PruneUKFKGroupByKeysRule
  2. EliminateAggRule

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@ZiheLiu ZiheLiu requested review from a team as code owners October 22, 2024 09:03
@ZiheLiu ZiheLiu force-pushed the opt/main/push_down_agg_refine2_ut branch 4 times, most recently from b06c5d4 to 327a884 Compare October 22, 2024 10:14
Seaven
Seaven previously approved these changes Oct 23, 2024
fnName.equals(FunctionSet.GROUP_CONCAT))) {
return false;
}
if (!context.getSessionVariable().isEnableUKFKOpt()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a behavior change? maybe we set enable_ukfk_opt = true by default later?

Copy link
Contributor Author

@ZiheLiu ZiheLiu Oct 31, 2024

Choose a reason for hiding this comment

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

Oh, this make a behavior change. Let me remove this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a new session variable enable_eliminate_agg (default is true) to avoid behaviour changed.

ColumnRefSet requiredOutputColumns = context.getTaskContext().getRequiredColumns();
List<ColumnRefOperator> groupBys = aggOp.getGroupingKeys();

// Retrieve non-UK columns from the first constraint that contains the UK column used in the GROUP BY clause.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why only considers the first constraint, what if group by keys contain multi UKs from different tables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestions. Instead of checking the first constraint, check all the the constraints now.

@ZiheLiu ZiheLiu requested review from a team as code owners October 31, 2024 10:45
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Oct 31, 2024
@wanpengfei-git wanpengfei-git requested a review from a team October 31, 2024 10:46
@ZiheLiu ZiheLiu removed request for a team October 31, 2024 11:39
Signed-off-by: zihe.liu <[email protected]>
Signed-off-by: zihe.liu <[email protected]>
Signed-off-by: zihe.liu <[email protected]>
Signed-off-by: zihe.liu <[email protected]>
@ZiheLiu ZiheLiu force-pushed the opt/main/push_down_agg_refine2_ut branch from 8bb5913 to 5069650 Compare October 31, 2024 14:03
Copy link

sonarcloud bot commented Oct 31, 2024

Copy link

github-actions bot commented Nov 1, 2024

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Nov 1, 2024

[FE Incremental Coverage Report]

pass : 180 / 183 (98.36%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/rule/transformation/PruneUKFKGroupByKeysRule.java 54 56 96.43% [115, 120]
🔵 com/starrocks/sql/optimizer/UKFKConstraintsCollector.java 79 80 98.75% [336]
🔵 com/starrocks/sql/optimizer/Optimizer.java 2 2 100.00% []
🔵 com/starrocks/qe/SessionVariable.java 4 4 100.00% []
🔵 com/starrocks/sql/optimizer/rule/transformation/EliminateAggRule.java 18 18 100.00% []
🔵 com/starrocks/sql/optimizer/operator/logical/LogicalAggregationOperator.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/rule/RuleType.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/rule/join/JoinOrder.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/MaterializedViewOptimizer.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/operator/UKFKConstraints.java 19 19 100.00% []

Copy link

github-actions bot commented Nov 1, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@Seaven Seaven merged commit c41f13c into StarRocks:main Nov 5, 2024
49 checks passed
renzhimin7 pushed a commit to renzhimin7/starrocks that referenced this pull request Nov 7, 2024
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.

4 participants