Plan Filter at the end of With clause
Reviewers: mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D727
This commit is contained in:
parent
d40319c111
commit
fe6d64066b
@ -472,13 +472,7 @@ auto GenReturnBody(LogicalOperator *input_op, bool advance_command,
|
||||
}
|
||||
last_op = new Produce(std::shared_ptr<LogicalOperator>(last_op),
|
||||
body.named_expressions());
|
||||
// Where may see new symbols so it comes after we generate Produce.
|
||||
if (body.where()) {
|
||||
last_op = new Filter(std::shared_ptr<LogicalOperator>(last_op),
|
||||
body.where()->expression_);
|
||||
}
|
||||
// Distinct in ReturnBody only makes Produce values unique, so plan after it.
|
||||
// Hopefully, it is more efficient to have Filter before Distinct.
|
||||
if (body.distinct()) {
|
||||
last_op = new Distinct(std::shared_ptr<LogicalOperator>(last_op),
|
||||
body.output_symbols());
|
||||
@ -498,6 +492,12 @@ auto GenReturnBody(LogicalOperator *input_op, bool advance_command,
|
||||
last_op =
|
||||
new Limit(std::shared_ptr<LogicalOperator>(last_op), body.limit());
|
||||
}
|
||||
// Where may see new symbols so it comes after we generate Produce and in
|
||||
// general, comes after any OrderBy, Skip or Limit.
|
||||
if (body.where()) {
|
||||
last_op = new Filter(std::shared_ptr<LogicalOperator>(last_op),
|
||||
body.where()->expression_);
|
||||
}
|
||||
return last_op;
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ TEST(TestLogicalPlanner, CreateWithOrderByWhere) {
|
||||
});
|
||||
auto plan = MakeLogicalPlan<RuleBasedPlanner>(storage, symbol_table, *dba);
|
||||
CheckPlan(*plan, symbol_table, ExpectCreateNode(), ExpectCreateExpand(), acc,
|
||||
ExpectProduce(), ExpectFilter(), ExpectOrderBy());
|
||||
ExpectProduce(), ExpectOrderBy(), ExpectFilter());
|
||||
}
|
||||
|
||||
TEST(TestLogicalPlanner, ReturnAddSumCountOrderBy) {
|
||||
@ -796,7 +796,7 @@ TEST(TestLogicalPlanner, CreateWithDistinctSumWhereReturn) {
|
||||
auto aggr = ExpectAggregate({sum}, {});
|
||||
auto plan = MakeLogicalPlan<RuleBasedPlanner>(storage, symbol_table, *dba);
|
||||
CheckPlan(*plan, symbol_table, ExpectCreateNode(), acc, aggr, ExpectProduce(),
|
||||
ExpectFilter(), ExpectDistinct(), ExpectProduce());
|
||||
ExpectDistinct(), ExpectFilter(), ExpectProduce());
|
||||
}
|
||||
|
||||
TEST(TestLogicalPlanner, MatchCrossReferenceVariable) {
|
||||
|
Loading…
Reference in New Issue
Block a user