diff --git a/backends-clickhouse/src/main/scala/org/apache/gluten/execution/CHHashAggregateExecTransformer.scala b/backends-clickhouse/src/main/scala/org/apache/gluten/execution/CHHashAggregateExecTransformer.scala index 1961fb0728a8..fcf6320f8ec4 100644 --- a/backends-clickhouse/src/main/scala/org/apache/gluten/execution/CHHashAggregateExecTransformer.scala +++ b/backends-clickhouse/src/main/scala/org/apache/gluten/execution/CHHashAggregateExecTransformer.scala @@ -56,6 +56,8 @@ object CHHashAggregateExecTransformer { aggExpr => aggExpr.mode match { case Partial | PartialMerge => + // For partial aggregate, the size of the result expressions of an aggregate expression + // is the same as aggBufferAttributes' length val aggBufferAttributesCount = aggExpr.aggregateFunction.aggBufferAttributes.length aggExpr.aggregateFunction match { case avg: Average => diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp index 9799933b3385..c71acd6b9b33 100644 --- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp +++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp @@ -123,11 +123,15 @@ void adjustOutput(const DB::QueryPlanPtr & query_plan, const substrait::PlanRel NamesWithAliases aliases; auto cols = query_plan->getCurrentHeader().getNamesAndTypesList(); if (cols.getNames().size() != static_cast(root_rel.root().names_size())) + { + LOG_ERROR(getLogger("SerializedPlanParser"), "invalid query plan:\n{}", PlanUtil::explainPlan(*query_plan)); + LOG_ERROR(getLogger("SerializedPlanParser"), "invalid substrait plan:\n{}", root_rel.DebugString()); throw Exception( ErrorCodes::LOGICAL_ERROR, "Missmatch result columns size. plan column size {}, subtrait plan size {}.", cols.getNames().size(), root_rel.root().names_size()); + } for (int i = 0; i < static_cast(cols.getNames().size()); i++) aliases.emplace_back(NameWithAlias(cols.getNames()[i], root_rel.root().names(i))); actions_dag.project(aliases);