From 8df6ee447bca721982b87e6b84c6379e999ae7e5 Mon Sep 17 00:00:00 2001 From: taiyang-li <654010905@qq.com> Date: Fri, 26 Jul 2024 15:48:54 +0800 Subject: [PATCH] fix uts --- cpp-ch/local-engine/Common/CHUtil.cpp | 15 ++++++++++++++- cpp-ch/local-engine/Common/CHUtil.h | 7 +++++++ .../arrayHighOrderFunctions.cpp | 8 +++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cpp-ch/local-engine/Common/CHUtil.cpp b/cpp-ch/local-engine/Common/CHUtil.cpp index 1be9c09a8c26..92f3b612ba63 100644 --- a/cpp-ch/local-engine/Common/CHUtil.cpp +++ b/cpp-ch/local-engine/Common/CHUtil.cpp @@ -477,6 +477,19 @@ const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeType( DB::createInternalCastOverloadResolver(cast_type, std::move(diagnostic)), std::move(children), result_name); } +const DB::ActionsDAG::Node * ActionsDAGUtil::convertNodeTypeIfNeeded( + DB::ActionsDAGPtr & actions_dag, + const DB::ActionsDAG::Node * node, + const DB::DataTypePtr & dst_type, + const std::string & result_name, + CastType cast_type) +{ + if (node->result_type->equals(*dst_type)) + return node; + + return convertNodeType(actions_dag, node, dst_type->getName(), result_name, cast_type); +} + String QueryPipelineUtil::explainPipeline(DB::QueryPipeline & pipeline) { DB::WriteBufferFromOwnString buf; @@ -844,7 +857,7 @@ void BackendInitializerUtil::initContexts(DB::Context::ConfigurationPtr config) size_t index_uncompressed_cache_size = config->getUInt64("index_uncompressed_cache_size", DEFAULT_INDEX_UNCOMPRESSED_CACHE_MAX_SIZE); double index_uncompressed_cache_size_ratio = config->getDouble("index_uncompressed_cache_size_ratio", DEFAULT_INDEX_UNCOMPRESSED_CACHE_SIZE_RATIO); global_context->setIndexUncompressedCache(index_uncompressed_cache_policy, index_uncompressed_cache_size, index_uncompressed_cache_size_ratio); - + String index_mark_cache_policy = config->getString("index_mark_cache_policy", DEFAULT_INDEX_MARK_CACHE_POLICY); size_t index_mark_cache_size = config->getUInt64("index_mark_cache_size", DEFAULT_INDEX_MARK_CACHE_MAX_SIZE); double index_mark_cache_size_ratio = config->getDouble("index_mark_cache_size_ratio", DEFAULT_INDEX_MARK_CACHE_SIZE_RATIO); diff --git a/cpp-ch/local-engine/Common/CHUtil.h b/cpp-ch/local-engine/Common/CHUtil.h index 98139fb49a5b..ef05fc525795 100644 --- a/cpp-ch/local-engine/Common/CHUtil.h +++ b/cpp-ch/local-engine/Common/CHUtil.h @@ -132,6 +132,13 @@ class ActionsDAGUtil const std::string & type_name, const std::string & result_name = "", DB::CastType cast_type = DB::CastType::nonAccurate); + + static const DB::ActionsDAG::Node * convertNodeTypeIfNeeded( + DB::ActionsDAGPtr & actions_dag, + const DB::ActionsDAG::Node * node, + const DB::DataTypePtr & dst_type, + const std::string & result_name = "", + DB::CastType cast_type = DB::CastType::nonAccurate); }; class QueryPipelineUtil diff --git a/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp b/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp index e509f12c9a6c..5cb5bf34517b 100644 --- a/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp +++ b/cpp-ch/local-engine/Parser/scalar_function_parser/arrayHighOrderFunctions.cpp @@ -95,9 +95,11 @@ class ArrayTransform : public FunctionParser /// U is the argument type of lambda function. In some cases Array(T) is not equal to Array(U). /// e.g. in the second query of https://github.com/apache/incubator-gluten/issues/6561, T is String, and U is Nullable(String) /// The difference of both types will result in runtime exceptions in function capture. - auto dst_array_type = std::make_shared(lambda_args.front().type); - const auto * dst_array_arg = ActionsDAGUtil::convertNodeType(actions_dag, parsed_args[0], dst_array_type->getName()); - std::cout << "actions_dag:" << actions_dag->dumpDAG() << std::endl; + const auto & src_array_type = parsed_args[0]->result_type; + DataTypePtr dst_array_type = std::make_shared(lambda_args.front().type); + if (isNullableOrLowCardinalityNullable(src_array_type)) + dst_array_type = std::make_shared(dst_array_type); + const auto * dst_array_arg = ActionsDAGUtil::convertNodeTypeIfNeeded(actions_dag, parsed_args[0], dst_array_type); return toFunctionNode(actions_dag, ch_func_name, {parsed_args[1], dst_array_arg}); }