From 4b24d7f930e0d13c416acb1ddae64d4daf095fb4 Mon Sep 17 00:00:00 2001 From: Chang Chen Date: Wed, 10 Jul 2024 21:29:49 +0800 Subject: [PATCH] Fix core dump --- cpp-ch/local-engine/Parser/TypeParser.cpp | 11 +++++++---- cpp-ch/local-engine/Parser/TypeParser.h | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cpp-ch/local-engine/Parser/TypeParser.cpp b/cpp-ch/local-engine/Parser/TypeParser.cpp index 301eabb7868e6..eb563f87fb560 100644 --- a/cpp-ch/local-engine/Parser/TypeParser.cpp +++ b/cpp-ch/local-engine/Parser/TypeParser.cpp @@ -239,7 +239,7 @@ DB::DataTypePtr TypeParser::parseType(const substrait::Type & substrait_type, st } -DB::Block TypeParser::buildBlockFromNamedStruct(const substrait::NamedStruct & struct_, const std::string & low_card_cols) +DB::Block TypeParser::buildBlockFromNamedStruct(const substrait::NamedStruct & struct_, const std::string & low_card_cols, bool collect_normal_col_only) { std::unordered_set low_card_columns; Poco::StringTokenizer tokenizer(low_card_cols, ","); @@ -250,9 +250,12 @@ DB::Block TypeParser::buildBlockFromNamedStruct(const substrait::NamedStruct & s assert(struct_.column_types_size() == struct_.struct_().types_size()); std::set non_normal_col_set; - for (int i = 0; i < struct_.column_types_size(); ++i) - if (struct_.column_types(i) != ::substrait::NamedStruct::NORMAL_COL) - non_normal_col_set.insert(i); + if (collect_normal_col_only) + { + for (int i = 0; i < struct_.column_types_size(); ++i) + if (struct_.column_types(i) != ::substrait::NamedStruct::NORMAL_COL) + non_normal_col_set.insert(i); + } DB::ColumnsWithTypeAndName internal_cols; internal_cols.reserve(struct_.names_size()); diff --git a/cpp-ch/local-engine/Parser/TypeParser.h b/cpp-ch/local-engine/Parser/TypeParser.h index 666effff45d37..4c4923bcd6266 100644 --- a/cpp-ch/local-engine/Parser/TypeParser.h +++ b/cpp-ch/local-engine/Parser/TypeParser.h @@ -44,7 +44,8 @@ namespace local_engine // low_card_cols is in format of "cola,colb". Currently does not nested column to be LowCardinality. static DB::Block buildBlockFromNamedStruct(const substrait::NamedStruct& struct_, - const std::string& low_card_cols = ""); + const std::string& low_card_cols = "", + bool collect_normal_col_only = false); /// Build block from substrait NamedStruct without DFS rules, different from buildBlockFromNamedStruct static DB::Block buildBlockFromNamedStructWithoutDFS(const substrait::NamedStruct& struct_);