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

Fix extract filter. #4823

Merged
merged 9 commits into from
Nov 18, 2022
1 change: 1 addition & 0 deletions src/graph/visitor/ExtractFilterExprVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ bool ExtractFilterExprVisitor::visitLogicalOr(LogicalExpression *expr) {
if (canNotPushedIndex != -1 || !canBeSplit) {
return false;
}
Copy link
Contributor

@czpmango czpmango Nov 7, 2022

Choose a reason for hiding this comment

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

Crashed at DCHECK(ok()) in ExprVisitorImpl.cpp:130.
Better to fix else branch:

 else {
      if (!canBePushed_) {
        return false;
      }
      operands[i]->accept(this);
    }

Alternatively, we could do some minor refactoring of this visitor, such as adding additional state variables other than "can" and "cannot" pairs to allow the internal logic to continue.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will lead to test fail.

canBePushed_ = true; // reset when the LogicalAnd can be split
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, this is not a good fix. Just fixed code path, but it's not a natural code logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's only what I can do.

canNotPushedIndex = i;
flags = std::move(flag);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/tck/features/bugfix/ExtractFilter.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2022 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License.
Feature: Test extract filter

Background:
Given a graph with space named "nba"

Scenario: Extract filter bug
When executing query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[:like]->(t) WHERE ( (1 == 1 AND (NOT is_edge(t))) OR (v.player.name == 'Tim Duncan')) RETURN v.player.name
"""
Then the result should be, in any order:
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to find the crash cases in community edition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't do that.

| v.player.name |
| 'Tim Duncan' |
| 'Tim Duncan' |