From f205459003263a4aece78b0ccc1adf337bf549ee Mon Sep 17 00:00:00 2001 From: Pat Okeeffe <85502298+paddyjok@users.noreply.github.com> Date: Tue, 14 Feb 2023 18:40:15 -0600 Subject: [PATCH] fixed issue with interplay between count(*) and _id column (#2250) --- sql3/planner/planoptimizer.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql3/planner/planoptimizer.go b/sql3/planner/planoptimizer.go index 3fc2ecdd6..90ac605b0 100644 --- a/sql3/planner/planoptimizer.go +++ b/sql3/planner/planoptimizer.go @@ -644,7 +644,13 @@ func tryToReplaceGroupByWithPQLAggregate(ctx context.Context, a *ExecutionPlanne } switch aggregable.AggExpression().Type().(type) { case *parser.DataTypeID, *parser.DataTypeString: - return thisNode, true, nil + // if it is any other column other than _id bail + ref, ok := aggregable.AggExpression().(*qualifiedRefPlanExpression) + if ok { + if !strings.EqualFold(ref.columnName, "_id") { + return thisNode, true, nil + } + } } }