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

push filter down traverse rule #4987

Merged
merged 3 commits into from
Dec 6, 2022

Conversation

jievince
Copy link
Contributor

@jievince jievince commented Dec 5, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@jievince jievince added the ready-for-testing PR: ready for the CI test label Dec 5, 2022
@jievince jievince force-pushed the push-filter-into-traverse branch 4 times, most recently from 99ca7ba to 80a990c Compare December 5, 2022 12:17
@jievince jievince force-pushed the push-filter-into-traverse branch 4 times, most recently from bc8e393 to f672427 Compare December 6, 2022 05:51
Comment on lines 498 to 507
# When executing query:
# """
# match (:player{name:"Tony Parker"})-[r]->() where exists(r.likeness) return r, exists({a:12}.a)
# """
# Then the result should be, in any order, with relax comparison:
# | r | exists({a:12}.a) |
# | [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] | true |
# | [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] | true |
# | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] | true |
When executing query:
Copy link
Contributor Author

@jievince jievince Dec 6, 2022

Choose a reason for hiding this comment

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

Ditto

Comment on lines 394 to 403
# When executing query:
# """
# MATCH (:player{name:"Tony Parker"})-[r]->() where exists(r.likeness) return r, exists({a:12}.a)
# """
# Then the result should be, in any order, with relax comparison:
# | r | exists({a:12}.a) |
# | [:like "Tony Parker"->"LaMarcus Aldridge" @0 {likeness: 90}] | true |
# | [:like "Tony Parker"->"Manu Ginobili" @0 {likeness: 95}] | true |
# | [:like "Tony Parker"->"Tim Duncan" @0 {likeness: 95}] | true |
When executing query:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Affected by #4815

Copy link
Contributor

Choose a reason for hiding this comment

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

This PR has merged, could these comment out tests be enabled ?

@@ -24,6 +24,19 @@ PushFilterDownProjectRule::PushFilterDownProjectRule() {
RuleSet::QueryRules().addRule(this);
}

bool PushFilterDownProjectRule::checkColumnExprKind(const Expression* expr) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copied from #4956

@Shylock-Hg
Copy link
Contributor

ent version has support it.

Copy link
Contributor

@yixinglu yixinglu left a comment

Choose a reason for hiding this comment

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

excellect!

static_cast<const Traverse*>(matched.dependencies[0].dependencies[0].node->node());
auto step = traverse->stepRange();
// step == nullptr means one step.
return step == nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

only support one step tranverse?

Copy link
Contributor Author

@jievince jievince Dec 6, 2022

Choose a reason for hiding this comment

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

For one step, the query looks like:

match (v1)-[e1]->(v2) where e1.likeness > 78

For multi step, the query should be like:

match (v1)-[e1*1..3]->(v2) where all(i in e1 where i.likeness > 78) 

The latter is rarely used currently, so just leave it for future.

@jievince
Copy link
Contributor Author

jievince commented Dec 6, 2022

ent version has support it.

Which rule? I don't find it.

@jievince
Copy link
Contributor Author

jievince commented Dec 6, 2022

ent version has support it.

They are not the same rule.

@jievince jievince requested a review from yixinglu December 6, 2022 07:19
static_cast<const Traverse*>(matched.dependencies[0].dependencies[0].node->node());
auto step = traverse->stepRange();
// step == nullptr means one step.
return step == nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

bool Traverse::isOneStep() {
  return !step;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

auto* tvGroupNode = matched.dependencies[0].dependencies[0].node;
auto* tv = static_cast<graph::Traverse*>(tvGroupNode->node());
auto& tvColNames = tv->colNames();
auto& edgeAlias = tvColNames.back();
Copy link
Contributor

@czpmango czpmango Dec 6, 2022

Choose a reason for hiding this comment

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

Hard code...?
Maybe this:

const auto& Traverse::getEdgeAlias() const {
    return colNames_.back();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hard code...? Maybe this:

const auto& Traverse::getEdgeAlias() const {
    return colNames.back();
}

Good job

}

auto* eFilter = tv->eFilter();
Expression* newEFilter = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

eFilter?LogicalExpression::makeAnd(pool, newfilterPicked, eFilter->clone()):newFilterPicked;

@jievince jievince force-pushed the push-filter-into-traverse branch from 36c75e2 to b90e3dd Compare December 6, 2022 09:19
czpmango
czpmango previously approved these changes Dec 6, 2022
Copy link
Contributor

@czpmango czpmango left a comment

Choose a reason for hiding this comment

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

LGTM

@jievince jievince force-pushed the push-filter-into-traverse branch from b90e3dd to a59e35f Compare December 6, 2022 09:24
@jievince jievince requested a review from czpmango December 6, 2022 09:31
@jievince jievince force-pushed the push-filter-into-traverse branch from a59e35f to 78f79aa Compare December 6, 2022 10:27
@jievince jievince force-pushed the push-filter-into-traverse branch from 78f79aa to db893c8 Compare December 6, 2022 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants