Fix three match cartesian sequential scanning (#1555)
This commit is contained in:
parent
46bfeb0023
commit
0fb3ae2d56
@ -511,10 +511,6 @@ class RuleBasedPlanner {
|
|||||||
|
|
||||||
std::set<ExpansionGroupId> visited_expansion_groups;
|
std::set<ExpansionGroupId> visited_expansion_groups;
|
||||||
|
|
||||||
last_op =
|
|
||||||
GenerateExpansionOnAlreadySeenSymbols(std::move(last_op), matching, visited_expansion_groups, symbol_table,
|
|
||||||
storage, bound_symbols, new_symbols, named_paths, filters, view);
|
|
||||||
|
|
||||||
// We want to create separate branches of scan operators for each expansion group group of patterns
|
// We want to create separate branches of scan operators for each expansion group group of patterns
|
||||||
// Whenever there are 2 scan branches, they will be joined with a Cartesian operator
|
// Whenever there are 2 scan branches, they will be joined with a Cartesian operator
|
||||||
|
|
||||||
@ -528,6 +524,14 @@ class RuleBasedPlanner {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_op =
|
||||||
|
GenerateExpansionOnAlreadySeenSymbols(std::move(last_op), matching, visited_expansion_groups, symbol_table,
|
||||||
|
storage, bound_symbols, new_symbols, named_paths, filters, view);
|
||||||
|
|
||||||
|
if (visited_expansion_groups.contains(expansion.expansion_group_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<LogicalOperator> starting_expansion_operator = nullptr;
|
std::unique_ptr<LogicalOperator> starting_expansion_operator = nullptr;
|
||||||
if (!initial_expansion_done) {
|
if (!initial_expansion_done) {
|
||||||
starting_expansion_operator = std::move(last_op);
|
starting_expansion_operator = std::move(last_op);
|
||||||
|
@ -73,6 +73,7 @@ add_subdirectory(inspect_query)
|
|||||||
add_subdirectory(filter_info)
|
add_subdirectory(filter_info)
|
||||||
add_subdirectory(queries)
|
add_subdirectory(queries)
|
||||||
add_subdirectory(garbage_collection)
|
add_subdirectory(garbage_collection)
|
||||||
|
add_subdirectory(query_planning)
|
||||||
|
|
||||||
copy_e2e_python_files(pytest_runner pytest_runner.sh "")
|
copy_e2e_python_files(pytest_runner pytest_runner.sh "")
|
||||||
copy_e2e_python_files(x x.sh "")
|
copy_e2e_python_files(x x.sh "")
|
||||||
|
6
tests/e2e/query_planning/CMakeLists.txt
Normal file
6
tests/e2e/query_planning/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
function(copy_query_planning_e2e_python_files FILE_NAME)
|
||||||
|
copy_e2e_python_files(query_planning ${FILE_NAME})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
copy_query_planning_e2e_python_files(common.py)
|
||||||
|
copy_query_planning_e2e_python_files(query_planning_cartesian.py)
|
24
tests/e2e/query_planning/common.py
Normal file
24
tests/e2e/query_planning/common.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Copyright 2023 Memgraph Ltd.
|
||||||
|
#
|
||||||
|
# Use of this software is governed by the Business Source License
|
||||||
|
# included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
|
# License, and you may not use this file except in compliance with the Business Source License.
|
||||||
|
#
|
||||||
|
# As of the Change Date specified in that file, in accordance with
|
||||||
|
# the Business Source License, use of this software will be governed
|
||||||
|
# by the Apache License, Version 2.0, included in the file
|
||||||
|
# licenses/APL.txt.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from gqlalchemy import Memgraph
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def memgraph(**kwargs) -> Memgraph:
|
||||||
|
memgraph = Memgraph()
|
||||||
|
|
||||||
|
yield memgraph
|
||||||
|
|
||||||
|
memgraph.drop_indexes()
|
||||||
|
memgraph.ensure_constraints([])
|
||||||
|
memgraph.drop_database()
|
42
tests/e2e/query_planning/query_planning_cartesian.py
Normal file
42
tests/e2e/query_planning/query_planning_cartesian.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Copyright 2023 Memgraph Ltd.
|
||||||
|
#
|
||||||
|
# Use of this software is governed by the Business Source License
|
||||||
|
# included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||||
|
# License, and you may not use this file except in compliance with the Business Source License.
|
||||||
|
#
|
||||||
|
# As of the Change Date specified in that file, in accordance with
|
||||||
|
# the Business Source License, use of this software will be governed
|
||||||
|
# by the Apache License, Version 2.0, included in the file
|
||||||
|
# licenses/APL.txt.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from common import memgraph
|
||||||
|
|
||||||
|
QUERY_PLAN = "QUERY PLAN"
|
||||||
|
|
||||||
|
|
||||||
|
def test_indexed_join_with_indices(memgraph):
|
||||||
|
memgraph.execute("CREATE INDEX ON :Node(id);")
|
||||||
|
|
||||||
|
expected_explain = [
|
||||||
|
f" * Produce {{a, b, r}}",
|
||||||
|
f" * Filter (a :Node), {{a.id}}",
|
||||||
|
f" * Expand (b)-[r:EDGE]-(a)",
|
||||||
|
f" * ScanAllByLabelPropertyValue (b :Node {{id}})",
|
||||||
|
f" * Once",
|
||||||
|
]
|
||||||
|
|
||||||
|
results = list(
|
||||||
|
memgraph.execute_and_fetch(
|
||||||
|
"EXPLAIN MATCH (a:Node {id: 1}) MATCH (b:Node {id: 2}) MATCH (a)-[r:EDGE]-(b) return a,b,r;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
actual_explain = [x[QUERY_PLAN] for x in results]
|
||||||
|
|
||||||
|
assert expected_explain == actual_explain
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(pytest.main([__file__, "-rA"]))
|
14
tests/e2e/query_planning/workloads.yaml
Normal file
14
tests/e2e/query_planning/workloads.yaml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
queries_cluster: &queries_cluster
|
||||||
|
cluster:
|
||||||
|
main:
|
||||||
|
args: ["--bolt-port", "7687", "--log-level=TRACE"]
|
||||||
|
log_file: "query_planning.log"
|
||||||
|
setup_queries: []
|
||||||
|
validation_queries: []
|
||||||
|
|
||||||
|
|
||||||
|
workloads:
|
||||||
|
- name: "Query planning cartesian"
|
||||||
|
binary: "tests/e2e/pytest_runner.sh"
|
||||||
|
args: ["query_planning/query_planning_cartesian.py"]
|
||||||
|
<<: *queries_cluster
|
Loading…
Reference in New Issue
Block a user