diff --git a/src/query/plan/pretty_print.cpp b/src/query/plan/pretty_print.cpp index 1db9fae5c..44ecb6fc8 100644 --- a/src/query/plan/pretty_print.cpp +++ b/src/query/plan/pretty_print.cpp @@ -357,7 +357,9 @@ json ToJson(const EdgeCreationInfo &edge_info, const DbAccessor &dba) { json ToJson(const Aggregate::Element &elem) { json json; - json["value"] = ToJson(elem.value); + if (elem.value) { + json["value"] = ToJson(elem.value); + } if (elem.key) { json["key"] = ToJson(elem.key); } diff --git a/tests/unit/plan_pretty_print.cpp b/tests/unit/plan_pretty_print.cpp index ee0a8972b..96eb42665 100644 --- a/tests/unit/plan_pretty_print.cpp +++ b/tests/unit/plan_pretty_print.cpp @@ -672,7 +672,8 @@ TEST_F(PrintToJsonTest, Aggregate) { {PROPERTY_LOOKUP("node", value), nullptr, Aggregation::Op::SUM, GetSymbol("sum")}, {PROPERTY_LOOKUP("node", value), PROPERTY_LOOKUP("node", color), - Aggregation::Op::COLLECT_MAP, GetSymbol("map")}}, + Aggregation::Op::COLLECT_MAP, GetSymbol("map")}, + {nullptr, nullptr, Aggregation::Op::COUNT, GetSymbol("count")}}, std::vector<Expression *>{PROPERTY_LOOKUP("node", type)}, std::vector<Symbol>{node_sym}); @@ -690,6 +691,10 @@ TEST_F(PrintToJsonTest, Aggregate) { "key" : "(PropertyLookup (Identifier \"node\") \"color\")", "op" : "collect", "output_symbol" : "map" + }, + { + "op": "count", + "output_symbol": "count" } ], "group_by" : [