Implement pretty printing CallProcedure operator
Reviewers: mferencevic, llugovic, ipaljak Reviewed By: mferencevic, llugovic, ipaljak Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2726
This commit is contained in:
parent
68a1a2da23
commit
008efaf243
@ -210,6 +210,16 @@ bool PlanPrinter::PreVisit(query::plan::Union &op) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlanPrinter::PreVisit(query::plan::CallProcedure &op) {
|
||||
WithPrintLn([&op](auto &out) {
|
||||
out << "* CallProcedure<" << op.procedure_name_ << "> {";
|
||||
utils::PrintIterable(out, op.result_symbols_, ", ",
|
||||
[](auto &out, const auto &sym) { out << sym.name(); });
|
||||
out << "}";
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlanPrinter::Visit(query::plan::Once &op) {
|
||||
WithPrintLn([](auto &out) { out << "* Once"; });
|
||||
return true;
|
||||
@ -793,6 +803,21 @@ bool PlanToJsonVisitor::PreVisit(Unwind &op) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlanToJsonVisitor::PreVisit(query::plan::CallProcedure &op) {
|
||||
json self;
|
||||
self["name"] = "CallProcedure";
|
||||
self["procedure_name"] = op.procedure_name_;
|
||||
self["arguments"] = ToJson(op.arguments_);
|
||||
self["result_fields"] = op.result_fields_;
|
||||
self["result_symbols"] = ToJson(op.result_symbols_);
|
||||
|
||||
op.input_->Accept(*this);
|
||||
self["input"] = PopOutput();
|
||||
|
||||
output_ = std::move(self);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PlanToJsonVisitor::PreVisit(Distinct &op) {
|
||||
json self;
|
||||
self["name"] = "Distinct";
|
||||
|
@ -82,6 +82,7 @@ class PlanPrinter : public virtual HierarchicalLogicalOperatorVisitor {
|
||||
bool PreVisit(Union &) override;
|
||||
|
||||
bool PreVisit(Unwind &) override;
|
||||
bool PreVisit(CallProcedure &) override;
|
||||
|
||||
bool Visit(Once &) override;
|
||||
|
||||
@ -194,6 +195,7 @@ class PlanToJsonVisitor : public virtual HierarchicalLogicalOperatorVisitor {
|
||||
bool PreVisit(Union &) override;
|
||||
|
||||
bool PreVisit(Unwind &) override;
|
||||
bool PreVisit(CallProcedure &) override;
|
||||
|
||||
bool Visit(Once &) override;
|
||||
|
||||
|
@ -951,3 +951,22 @@ TEST_F(PrintToJsonTest, Cartesian) {
|
||||
}
|
||||
})sep");
|
||||
}
|
||||
|
||||
TEST_F(PrintToJsonTest, CallProcedure) {
|
||||
query::plan::CallProcedure call_op;
|
||||
call_op.input_ = std::make_shared<Once>();
|
||||
call_op.procedure_name_ = "mg.reload";
|
||||
call_op.arguments_ = {LITERAL("example")};
|
||||
call_op.result_fields_ = {"name", "signature"};
|
||||
call_op.result_symbols_ = {GetSymbol("name_alias"),
|
||||
GetSymbol("signature_alias")};
|
||||
Check(&call_op, R"sep(
|
||||
{
|
||||
"arguments" : ["\"example\""],
|
||||
"input" : { "name" : "Once" },
|
||||
"name" : "CallProcedure",
|
||||
"procedure_name" : "mg.reload",
|
||||
"result_fields" : ["name", "signature"],
|
||||
"result_symbols" : ["name_alias", "signature_alias"]
|
||||
})sep");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user