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

[opt](nereids) support pushing down aggr distinct through join #43380

Merged
merged 17 commits into from
Dec 5, 2024

Conversation

xzj7019
Copy link
Contributor

@xzj7019 xzj7019 commented Nov 6, 2024

What problem does this PR solve?

support pushing down agg distinct through join on one side.

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No colde files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.
  • Release note

    None

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@xzj7019 xzj7019 marked this pull request as draft November 6, 2024 13:00
@xzj7019 xzj7019 marked this pull request as ready for review November 19, 2024 06:16
@xzj7019 xzj7019 marked this pull request as draft November 19, 2024 06:16
@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch 2 times, most recently from 7a772d1 to 29c1de5 Compare November 28, 2024 13:37
@xzj7019
Copy link
Contributor Author

xzj7019 commented Nov 28, 2024

run buildall

@xzj7019 xzj7019 marked this pull request as ready for review November 28, 2024 13:37
@xzj7019 xzj7019 changed the title [opt](nereids) support pushdown agg distinct through join [opt](nereids) support pushing down aggr distinct through join Nov 28, 2024
@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from 29c1de5 to 964514c Compare November 29, 2024 02:40
@xzj7019
Copy link
Contributor Author

xzj7019 commented Nov 29, 2024

run buildall

.when(agg -> agg.child().child().getOtherJoinConjuncts().isEmpty())
.when(agg -> !agg.isGenerated())
.whenNot(agg -> agg.getAggregateFunctions().isEmpty())
.whenNot(agg -> agg.child().children().stream().anyMatch(p -> p instanceof LogicalAggregate))
Copy link
Contributor

Choose a reason for hiding this comment

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

agg -> agg.child().children().stream().anyMatch(p -> p instanceof LogicalAggregate) , this is always false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx, should be changed to .whenNot(agg -> agg.child()
.child(0).children().stream().anyMatch(p -> p instanceof LogicalAggregate))

leftFuncs.forEach(func -> {
Alias alias = func.alias("PDADT_" + func.getName());
leftSlotToOutput.put((Slot) func.child(0), alias);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

map leftSlotToOutput value seems to be useless

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from 964514c to e99aa8c Compare November 29, 2024 06:50
@xzj7019
Copy link
Contributor Author

xzj7019 commented Nov 29, 2024

run buildall

Copy link
Contributor

PR approved by anyone and no changes requested.

@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from e99aa8c to 8076eb0 Compare November 29, 2024 08:16
@xzj7019
Copy link
Contributor Author

xzj7019 commented Nov 29, 2024

run buildall

@xzj7019
Copy link
Contributor Author

xzj7019 commented Nov 29, 2024

run cloud_p0

1 similar comment
@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 2, 2024

run cloud_p0

public List<Rule> buildRules() {
return ImmutableList.of(
logicalAggregate(logicalProject(innerLogicalJoin()))
.when(agg -> agg.child().isAllSlots())
Copy link
Contributor

Choose a reason for hiding this comment

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

agg.child().isAllSlots()
is this restriction too strong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aggr with distinct pushing down has special rewrite logic and restrict this case carefully by safety

return ImmutableList.of(
logicalAggregate(logicalProject(innerLogicalJoin()))
.when(agg -> agg.child().isAllSlots())
.when(agg -> agg.child().child().getOtherJoinConjuncts().isEmpty())
Copy link
Contributor

Choose a reason for hiding this comment

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

"getOtherJoinConjuncts().isEmpty()"
how about remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leave this clean up task for the whole series of aggr pushing down rules

@englefly
Copy link
Contributor

englefly commented Dec 2, 2024

why it is called oneSide? it could push down through both sides

@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 2, 2024

run cloud_p0

@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from 8076eb0 to b243038 Compare December 2, 2024 03:28
@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 2, 2024

run buildall

@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 2, 2024

run cloud_p0

@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from bf3e09d to 5e048db Compare December 2, 2024 09:27
@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 2, 2024

run buildall

@xzj7019 xzj7019 force-pushed the pushdown_agg_distinct branch from c85ccfa to 9e4d53c Compare December 4, 2024 07:15
@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 4, 2024

run buildall

@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 4, 2024

run p0

1 similar comment
@xzj7019
Copy link
Contributor Author

xzj7019 commented Dec 4, 2024

run p0

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 5, 2024
Copy link
Contributor

github-actions bot commented Dec 5, 2024

PR approved by at least one committer and no changes requested.

@morrySnow morrySnow merged commit bf4ba66 into apache:master Dec 5, 2024
22 of 23 checks passed
morrySnow pushed a commit that referenced this pull request Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/3.0.4-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants