From 8a94b16e79e86f4497103a34fbf51177c355c6ad Mon Sep 17 00:00:00 2001 From: Matej Ferencevic <matej.ferencevic@memgraph.io> Date: Mon, 25 Nov 2019 11:02:34 +0100 Subject: [PATCH] Fix parameters for PROFILE queries Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2563 --- src/query/interpreter.cpp | 2 +- tests/unit/interpreter.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 7b7fab805..4cfaf9bec 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -767,7 +767,7 @@ PreparedQuery PrepareProfileQuery( {"OPERATOR", "ACTUAL HITS", "RELATIVE TIME", "ABSOLUTE TIME"}, std::move(parsed_query.required_privileges), [plan = std::move(cypher_query_plan), - parameters = std::move(parsed_query.parameters), summary, dba, + parameters = std::move(parsed_inner_query.parameters), summary, dba, execution_memory](AnyStream *stream) { // No output symbols are given so that nothing is streamed. auto ctx = PullAllPlan(stream, *plan, parameters, {}, true, summary, diff --git a/tests/unit/interpreter.cpp b/tests/unit/interpreter.cpp index 65b27ec19..143376f3f 100644 --- a/tests/unit/interpreter.cpp +++ b/tests/unit/interpreter.cpp @@ -433,3 +433,28 @@ TEST_F(InterpreterTest, ProfileQueryWithParams) { EXPECT_EQ(interpreter_context_.plan_cache.size(), 1U); EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U); } + +TEST_F(InterpreterTest, ProfileQueryWithLiterals) { + EXPECT_EQ(interpreter_context_.plan_cache.size(), 0U); + EXPECT_EQ(interpreter_context_.ast_cache.size(), 0U); + auto stream = Interpret( + "PROFILE UNWIND range(1, 1000) AS x CREATE (:Node {id: x});", {}); + std::vector<std::string> expected_header{"OPERATOR", "ACTUAL HITS", + "RELATIVE TIME", "ABSOLUTE TIME"}; + EXPECT_EQ(stream.GetHeader(), expected_header); + std::vector<std::string> expected_rows{"* CreateNode", "* Unwind", "* Once"}; + ASSERT_EQ(stream.GetResults().size(), expected_rows.size()); + auto expected_it = expected_rows.begin(); + for (const auto &row : stream.GetResults()) { + ASSERT_EQ(row.size(), 4U); + EXPECT_EQ(row.front().ValueString(), *expected_it); + ++expected_it; + } + // We should have a plan cache for UNWIND ... + EXPECT_EQ(interpreter_context_.plan_cache.size(), 1U); + // We should have AST cache for PROFILE ... and for inner UNWIND ... + EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U); + Interpret("UNWIND range(42, 4242) AS x CREATE (:Node {id: x});", {}); + EXPECT_EQ(interpreter_context_.plan_cache.size(), 1U); + EXPECT_EQ(interpreter_context_.ast_cache.size(), 2U); +}