Skip to content

Commit

Permalink
fix parse alias function failed
Browse files Browse the repository at this point in the history
  • Loading branch information
liuneng1994 committed Apr 12, 2022
1 parent 502c26c commit a1c4e68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,22 +429,23 @@ DB::ActionsDAGPtr local_engine::SerializedPlanParser::parseFunction(
{
actions_dag = std::make_shared<ActionsDAG>(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
{
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;
Expand Down
2 changes: 2 additions & 0 deletions utils/local-engine/Parser/SerializedPlanParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ static const std::map<std::string, std::string> SCALAR_FUNCTIONS = {
{"alias", "alias"}
};

static const std::set<std::string> FUNCTION_NEED_KEEP_ARGUMENTS = {"alias"};

struct QueryContext {
std::shared_ptr<DB::StorageInMemoryMetadata> metadata;
std::shared_ptr<local_engine::CustomStorageMergeTree> custom_storage_merge_tree;
Expand Down

0 comments on commit a1c4e68

Please sign in to comment.