Merge branch 'master' into 1529-configure-sonarcloud-for-automatic-analysis
This commit is contained in:
commit
108d83cc8c
@ -3464,7 +3464,7 @@ class AggregateCursor : public Cursor {
|
|||||||
SCOPED_PROFILE_OP_BY_REF(self_);
|
SCOPED_PROFILE_OP_BY_REF(self_);
|
||||||
|
|
||||||
if (!pulled_all_input_) {
|
if (!pulled_all_input_) {
|
||||||
if (!ProcessAll(&frame, &context) && self_.AreAllAggregationsForCollecting()) return false;
|
if (!ProcessAll(&frame, &context) && !self_.group_by_.empty()) return false;
|
||||||
pulled_all_input_ = true;
|
pulled_all_input_ = true;
|
||||||
aggregation_it_ = aggregation_.begin();
|
aggregation_it_ = aggregation_.begin();
|
||||||
|
|
||||||
@ -3824,12 +3824,6 @@ UniqueCursorPtr Aggregate::MakeCursor(utils::MemoryResource *mem) const {
|
|||||||
return MakeUniqueCursorPtr<AggregateCursor>(mem, *this, mem);
|
return MakeUniqueCursorPtr<AggregateCursor>(mem, *this, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Aggregate::AreAllAggregationsForCollecting() const -> bool {
|
|
||||||
return std::all_of(aggregations_.begin(), aggregations_.end(), [](const auto &agg) {
|
|
||||||
return agg.op == Aggregation::Op::COLLECT_LIST || agg.op == Aggregation::Op::COLLECT_MAP;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Skip::Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression)
|
Skip::Skip(const std::shared_ptr<LogicalOperator> &input, Expression *expression)
|
||||||
: input_(input), expression_(expression) {}
|
: input_(input), expression_(expression) {}
|
||||||
|
|
||||||
|
@ -1759,8 +1759,6 @@ class Aggregate : public memgraph::query::plan::LogicalOperator {
|
|||||||
Aggregate(const std::shared_ptr<LogicalOperator> &input, const std::vector<Element> &aggregations,
|
Aggregate(const std::shared_ptr<LogicalOperator> &input, const std::vector<Element> &aggregations,
|
||||||
const std::vector<Expression *> &group_by, const std::vector<Symbol> &remember);
|
const std::vector<Expression *> &group_by, const std::vector<Symbol> &remember);
|
||||||
|
|
||||||
auto AreAllAggregationsForCollecting() const -> bool;
|
|
||||||
|
|
||||||
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
bool Accept(HierarchicalLogicalOperatorVisitor &visitor) override;
|
||||||
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
UniqueCursorPtr MakeCursor(utils::MemoryResource *) const override;
|
||||||
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
std::vector<Symbol> ModifiedSymbols(const SymbolTable &) const override;
|
||||||
|
@ -425,6 +425,4 @@ Feature: Aggregations
|
|||||||
"""
|
"""
|
||||||
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
|
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
|
||||||
"""
|
"""
|
||||||
Then the result should be:
|
Then the result should be empty
|
||||||
| id |
|
|
||||||
| null |
|
|
||||||
|
@ -425,6 +425,4 @@ Feature: Aggregations
|
|||||||
"""
|
"""
|
||||||
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
|
MATCH (subnet:Subnet) WHERE FALSE WITH subnet, count(subnet.ip) as ips RETURN id(subnet) as id
|
||||||
"""
|
"""
|
||||||
Then the result should be:
|
Then the result should be empty
|
||||||
| id |
|
|
||||||
| null |
|
|
||||||
|
@ -250,30 +250,23 @@ TYPED_TEST(QueryPlanAggregateOps, WithData) {
|
|||||||
TYPED_TEST(QueryPlanAggregateOps, WithoutDataWithGroupBy) {
|
TYPED_TEST(QueryPlanAggregateOps, WithoutDataWithGroupBy) {
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::COUNT});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::COUNT});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Int);
|
|
||||||
EXPECT_EQ(results[0][0].ValueInt(), 0);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::SUM});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::SUM});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Int);
|
|
||||||
EXPECT_EQ(results[0][0].ValueInt(), 0);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::AVG});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::AVG});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::MIN});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::MIN});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::MAX});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::MAX});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, false, {Aggregation::Op::COLLECT_LIST});
|
auto results = this->AggregationResults(true, false, {Aggregation::Op::COLLECT_LIST});
|
||||||
@ -666,30 +659,23 @@ TYPED_TEST(QueryPlanAggregateOps, WithDataDistinct) {
|
|||||||
TYPED_TEST(QueryPlanAggregateOps, WithoutDataWithDistinctAndWithGroupBy) {
|
TYPED_TEST(QueryPlanAggregateOps, WithoutDataWithDistinctAndWithGroupBy) {
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::COUNT});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::COUNT});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Int);
|
|
||||||
EXPECT_EQ(results[0][0].ValueInt(), 0);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::SUM});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::SUM});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Int);
|
|
||||||
EXPECT_EQ(results[0][0].ValueInt(), 0);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::AVG});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::AVG});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::MIN});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::MIN});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::MAX});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::MAX});
|
||||||
EXPECT_EQ(results.size(), 1);
|
EXPECT_EQ(results.size(), 0);
|
||||||
EXPECT_EQ(results[0][0].type(), TypedValue::Type::Null);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto results = this->AggregationResults(true, true, {Aggregation::Op::COLLECT_LIST});
|
auto results = this->AggregationResults(true, true, {Aggregation::Op::COLLECT_LIST});
|
||||||
|
Loading…
Reference in New Issue
Block a user