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

Run filter-into-join rule early for subqueries and disable project-filter rule #15511

Merged
merged 5 commits into from
Jan 4, 2024

Conversation

kgyrtkirk
Copy link
Member

  • FILTER_INTO_JOIN is mainly run along with the other rules with the Volcano planner; however if the query starts highly underdefined (join conditions in the where clauses) that generic query could give a lot of room for the other rules to play around with
    • only enabled it for when the join uses subqueries for its inputs
  • PROJECT_FILTER rule is not that usefull; and could increase planning times by providing new plans

Fixes #XXXX.

Description

Fixed the bug ...

Renamed the class ...

Added a forbidden-apis entry ...

Release note


Key changed/added classes in this PR
  • MyFoo
  • OurBar
  • TheirBaz

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@github-actions github-actions bot added Area - Batch Ingestion Area - Querying Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Dec 7, 2023
@kgyrtkirk kgyrtkirk marked this pull request as ready for review December 7, 2023 19:03
@@ -224,11 +224,16 @@ public CalciteRulesManager(final Set<ExtensionCalciteRuleProvider> extensionCalc
public List<Program> programs(final PlannerContext plannerContext)
{
// Program that pre-processes the tree before letting the full-on VolcanoPlanner loose.
List<RelOptRule> hepRules = new ArrayList<RelOptRule>(REDUCTION_RULES);
if (plannerContext.getJoinAlgorithm().requiresSubquery()) {
hepRules.add(CoreRules.FILTER_INTO_JOIN);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please explain the reasoning about why we want this for sortMerge, but not for broadcast join? (that's essentially what requiresSubquery is checking)

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a very usefull rule; and would be good to run it early for every plan - however it could even by itself could create ScanQuery beneath Join-s like these which is good; however based on the discussions in #9843 and #9773
...it might not be the best for Druid;

so I've decided to only enable it when also the FANCY_JOIN rules are added - as those will pill in this rule anyway.

@kgyrtkirk kgyrtkirk requested a review from gianm December 13, 2023 11:45
@@ -84,14 +85,15 @@ public class CalciteRulesManager
* those functions).
* 3) {@link CoreRules#JOIN_COMMUTE}, {@link JoinPushThroughJoinRule#RIGHT}, {@link JoinPushThroughJoinRule#LEFT},
* and {@link CoreRules#FILTER_INTO_JOIN}, which are part of {@link #FANCY_JOIN_RULES}.
* 4) {@link CoreRules#PROJECT_FILTER_TRANSPOSE} because PartialDruidQuery would like to have the Project on top of the Filter -
* this rule could create a lot of non-usefull plans.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* this rule could create a lot of non-usefull plans.
* this rule could create a lot of non-useful plans that unnecessarily increase the planning time.

@abhishekagarwal87 abhishekagarwal87 merged commit b9679d0 into apache:master Jan 4, 2024
83 checks passed
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants