Skip to content

Commit

Permalink
fix empty filter (#5740)
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 authored Oct 17, 2023
1 parent 496cfb0 commit 38b3e9d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/graph/optimizer/rule/EliminateFilterRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ StatusOr<OptRule::TransformResult> EliminateFilterRule::transform(
auto filterGroupNode = matched.node;
auto filter = static_cast<const Filter*>(filterGroupNode->node());

auto newValue = ValueNode::make(octx->qctx(), nullptr, DataSet(filter->colNames()));
newValue->setOutputVar(filter->outputVar());
auto newValueGroupNode = OptGroupNode::create(octx, newValue, filterGroupNode->group());

auto newStart = StartNode::make(octx->qctx());
auto newStartGroup = OptGroup::create(octx);
newStartGroup->makeGroupNode(newStart);

auto newValue = ValueNode::make(octx->qctx(), newStart, DataSet(filter->colNames()));
newValue->setOutputVar(filter->outputVar());
auto newValueGroupNode = OptGroupNode::create(octx, newValue, filterGroupNode->group());
newValueGroupNode->dependsOn(newStartGroup);

TransformResult result;
Expand Down
4 changes: 4 additions & 0 deletions src/graph/planner/plan/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,5 +1083,9 @@ std::unique_ptr<PlanNodeDescription> FulltextIndexScan::explain() const {
return desc;
}

PlanNode* ValueNode::clone() const {
return ValueNode::make(qctx_, nullptr, value_);
}

} // namespace graph
} // namespace nebula
2 changes: 2 additions & 0 deletions src/graph/planner/plan/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,8 @@ class ValueNode : public SingleInputNode {
return qctx->objPool()->makeAndAdd<ValueNode>(qctx, dep, std::move(value));
}

PlanNode* clone() const override;

Value value() const {
return value_;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/tck/features/optimizer/ElimintateInvalidProp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ Feature: Eliminate invalid property filter
| 0 | Project | 1 | |
| 1 | Value | 2 | |
| 2 | Start | | |

Scenario: Elimintate Empty value
When executing query:
"""
MATCH (a2:player) WHERE 28==0.63
MATCH (b)-[e4]->(a2) WHERE 18 <= a2.player.age
RETURN a2
"""
Then the result should be, in any order:
| a2 |

0 comments on commit 38b3e9d

Please sign in to comment.