From a1c4e68752d04591fd7aa1b39ddf8803498a60e0 Mon Sep 17 00:00:00 2001 From: "neng.liu" <1398775315@qq.com> Date: Tue, 12 Apr 2022 16:07:36 +0800 Subject: [PATCH] fix parse alias function failed --- utils/local-engine/Parser/SerializedPlanParser.cpp | 7 ++++--- utils/local-engine/Parser/SerializedPlanParser.h | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/local-engine/Parser/SerializedPlanParser.cpp b/utils/local-engine/Parser/SerializedPlanParser.cpp index 79910d771a85..fc518f533c72 100644 --- a/utils/local-engine/Parser/SerializedPlanParser.cpp +++ b/utils/local-engine/Parser/SerializedPlanParser.cpp @@ -429,13 +429,16 @@ DB::ActionsDAGPtr local_engine::SerializedPlanParser::parseFunction( { actions_dag = std::make_shared(blockToNameAndTypeList(input.header)); } + auto function_signature = this->function_mapping.at(std::to_string(rel.scalar_function().function_reference())); + auto function_name = getFunctionName(function_signature, rel.scalar_function().output_type()); DB::ActionsDAG::NodeRawConstPtrs args; for (const auto & arg : scalar_function.args()) { if (arg.has_scalar_function()) { std::string arg_name; - parseFunction(input, arg, arg_name, actions_dag, false); + bool keep_arg = local_engine::FUNCTION_NEED_KEEP_ARGUMENTS.contains(function_name); + parseFunction(input, arg, arg_name, actions_dag, keep_arg); args.emplace_back(&actions_dag->getNodes().back()); } else @@ -443,8 +446,6 @@ DB::ActionsDAGPtr local_engine::SerializedPlanParser::parseFunction( args.emplace_back(parseArgument(actions_dag, arg)); } } - auto function_signature = this->function_mapping.at(std::to_string(rel.scalar_function().function_reference())); - auto function_name = getFunctionName(function_signature, rel.scalar_function().output_type()); if (function_name == "alias") { result_name = args[0]->result_name; diff --git a/utils/local-engine/Parser/SerializedPlanParser.h b/utils/local-engine/Parser/SerializedPlanParser.h index f5f5a078daa7..774d692ce6ec 100644 --- a/utils/local-engine/Parser/SerializedPlanParser.h +++ b/utils/local-engine/Parser/SerializedPlanParser.h @@ -75,6 +75,8 @@ static const std::map SCALAR_FUNCTIONS = { {"alias", "alias"} }; +static const std::set FUNCTION_NEED_KEEP_ARGUMENTS = {"alias"}; + struct QueryContext { std::shared_ptr metadata; std::shared_ptr custom_storage_merge_tree;