Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VL] Support Decimal type in Gluten #378

Merged
merged 2 commits into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions utils/local-engine/Parser/SerializedPlanParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,8 +1268,8 @@ SerializedPlanParser::getFunctionName(const std::string & function_signature, co
}
else if (function_name == "check_overflow")
{
if (args.size() != 2)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "check_overflow function requires two args.");
if (args.size() < 2)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "check_overflow function requires at least two args.");
ch_function_name = getDecimalFunction(output_type.decimal(), args.at(1).value().literal().boolean());
}
else
Expand Down Expand Up @@ -1423,8 +1423,11 @@ const ActionsDAG::Node * SerializedPlanParser::parseFunctionWithDAG(

if (function_signature.find("check_overflow:", 0) != function_signature.npos)
{
if (scalar_function.arguments().size() != 2)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "check_overflow function requires two args.");
if (scalar_function.arguments().size() < 2)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "check_overflow function requires at least two args.");

ActionsDAG::NodeRawConstPtrs new_args;
new_args.reserve(2);

// if toDecimalxxOrNull, first arg need string type
if (scalar_function.arguments().at(1).value().literal().boolean())
Expand All @@ -1437,15 +1440,19 @@ const ActionsDAG::Node * SerializedPlanParser::parseFunctionWithDAG(
join(to_string_args, ',', to_string_cast_args_name);
result_name = check_overflow_args_trans_function + "(" + to_string_cast_args_name + ")";
const auto * to_string_cast_node = &actions_dag->addFunction(to_string_cast, to_string_args, result_name);
args[0] = to_string_cast_node;
new_args.emplace_back(to_string_cast_node);
}
else
{
new_args.emplace_back(args[0]);
}

// delete the latest arg
args.pop_back();
auto type = std::make_shared<DataTypeUInt32>();
UInt32 scale = rel.scalar_function().output_type().decimal().scale();
args.emplace_back(
new_args.emplace_back(
&actions_dag->addColumn(ColumnWithTypeAndName(type->createColumnConst(1, scale), type, getUniqueName(toString(scale)))));

args = std::move(new_args);
}

auto function_builder = FunctionFactory::instance().get(function_name, context);
Expand Down