This is an automated email from the ASF dual-hosted git repository.

exmy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new d1da37fb7 [GLUTEN-6878][CH] Avoid name collisions in naming aggregate 
result (#6886)
d1da37fb7 is described below

commit d1da37fb73dd2c41b738863b714d4601cb628480
Author: lgbo <[email protected]>
AuthorDate: Fri Aug 16 18:36:46 2024 +0800

    [GLUTEN-6878][CH] Avoid name collisions in naming aggregate result (#6886)
---
 cpp-ch/local-engine/Parser/AggregateRelParser.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cpp-ch/local-engine/Parser/AggregateRelParser.cpp 
b/cpp-ch/local-engine/Parser/AggregateRelParser.cpp
index bf5129f13..494403cf4 100644
--- a/cpp-ch/local-engine/Parser/AggregateRelParser.cpp
+++ b/cpp-ch/local-engine/Parser/AggregateRelParser.cpp
@@ -195,7 +195,8 @@ void AggregateRelParser::addPreProjection()
 
 void AggregateRelParser::buildAggregateDescriptions(AggregateDescriptions & 
descriptions)
 {
-    auto build_result_column_name = [](const String & function_name, const 
Array & params, const Strings & arg_names, substrait::AggregationPhase phase)
+    const auto & current_plan_header = plan->getCurrentDataStream().header;
+    auto build_result_column_name = [this, current_plan_header](const String & 
function_name, const Array & params, const Strings & arg_names, 
substrait::AggregationPhase phase)
     {
         if (phase == 
substrait::AggregationPhase::AGGREGATION_PHASE_INTERMEDIATE_TO_RESULT)
         {
@@ -219,7 +220,12 @@ void 
AggregateRelParser::buildAggregateDescriptions(AggregateDescriptions & desc
         result += "(";
         result += boost::algorithm::join(arg_names, ",");
         result += ")";
-        return result;
+        // Make the name unique to avoid name collision(issue #6878).
+        auto res = this->getUniqueName(result);
+        // Just a check for remining this issue.
+        if (current_plan_header.findByName(res))
+            throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Name ({}) 
collision in header: {}", res, current_plan_header.dumpStructure());
+        return res;
     };
 
     for (auto & agg_info : aggregates)
@@ -228,6 +234,7 @@ void 
AggregateRelParser::buildAggregateDescriptions(AggregateDescriptions & desc
         const auto & measure = agg_info.measure->measure();
         description.column_name
             = build_result_column_name(agg_info.function_name, 
agg_info.params, agg_info.arg_column_names, measure.phase());
+
         agg_info.measure_column_name = description.column_name;
         // std::cout << "description.column_name:" << description.column_name 
<< std::endl;
         description.argument_names = agg_info.arg_column_names;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to