Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jacktengg committed Oct 21, 2024
1 parent 67d5d00 commit d9c5c37
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 16 deletions.
3 changes: 2 additions & 1 deletion be/src/vec/exec/scan/vfile_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ Status VFileScanner::_cast_to_input_block(Block* block) {
ColumnsWithTypeAndName arguments {
arg, {data_type->create_column(), data_type, slot_desc->col_name()}};
auto func_cast = SimpleFunctionFactory::instance().get_function(
"CAST", arguments, return_type, runtime_state()->enable_decimal256());
"CAST", arguments, return_type,
{.enable_decimal256 = runtime_state()->enable_decimal256()});
idx = _src_block_name_to_idx[slot_desc->col_name()];
RETURN_IF_ERROR(
func_cast->execute(nullptr, *_src_block_ptr, {idx}, idx, arg.column->size()));
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/exprs/vcase_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ Status VCaseExpr::prepare(RuntimeState* state, const RowDescriptor& desc, VExprC
}

_function = SimpleFunctionFactory::instance().get_function(
_function_name, argument_template, _data_type, state->enable_decimal256());
_function_name, argument_template, _data_type,
{.enable_decimal256 = state->enable_decimal256()});
if (_function == nullptr) {
return Status::NotSupported("vcase_expr Function {} is not implemented",
_fn.name.function_name);
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/exprs/vcast_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ doris::Status VCastExpr::prepare(doris::RuntimeState* state, const doris::RowDes
argument_template.emplace_back(nullptr, child->data_type(), child_name);
argument_template.emplace_back(_cast_param, _cast_param_data_type, _target_data_type_name);
_function = SimpleFunctionFactory::instance().get_function(
function_name, argument_template, _data_type, state->enable_decimal256());
function_name, argument_template, _data_type,
{.enable_decimal256 = state->enable_decimal256()});

if (_function == nullptr) {
return Status::NotSupported("Function {} is not implemented", _fn.name.function_name);
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/exprs/vectorized_fn_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ Status VectorizedFnCall::prepare(RuntimeState* state, const RowDescriptor& desc,
} else {
// get the function. won't prepare function.
_function = SimpleFunctionFactory::instance().get_function(
_fn.name.function_name, argument_template, _data_type, state->enable_decimal256(),
state->be_exec_version());
_fn.name.function_name, argument_template, _data_type,
{.enable_decimal256 = state->enable_decimal256()}, state->be_exec_version());
}
if (_function == nullptr) {
return Status::InternalError("Could not find function {}, arg {} return {} ",
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/exprs/vin_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Status VInPredicate::prepare(RuntimeState* state, const RowDescriptor& desc,
real_function_name = "collection_" + real_function_name;
}
_function = SimpleFunctionFactory::instance().get_function(
real_function_name, argument_template, _data_type, state->enable_decimal256());
real_function_name, argument_template, _data_type,
{.enable_decimal256 = state->enable_decimal256()});
if (_function == nullptr) {
return Status::NotSupported("Function {} is not implemented", real_function_name);
}
Expand Down
3 changes: 2 additions & 1 deletion be/src/vec/exprs/vmatch_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Status VMatchPredicate::prepare(RuntimeState* state, const RowDescriptor& desc,
}

_function = SimpleFunctionFactory::instance().get_function(
_fn.name.function_name, argument_template, _data_type, state->enable_decimal256());
_fn.name.function_name, argument_template, _data_type,
{.enable_decimal256 = state->enable_decimal256()});
if (_function == nullptr) {
std::string type_str;
for (auto arg : argument_template) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/exprs/vtopn_pred.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class VTopNPred : public VExpr {

_function = SimpleFunctionFactory::instance().get_function(
_predicate->is_asc() ? "le" : "ge", argument_template, _data_type,
state->enable_decimal256(), state->be_exec_version());
{.enable_decimal256 = state->enable_decimal256()}, state->be_exec_version());
if (!_function) {
return Status::InternalError("get function failed");
}
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/functions/comparison_equal_for_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class FunctionEqForNull : public IFunction {

auto func_eq = SimpleFunctionFactory::instance().get_function(
"eq", eq_columns, return_type,
context ? context->state()->enable_decimal256() : false);
{.enable_decimal256 = context ? context->state()->enable_decimal256() : false});
DCHECK(func_eq) << fmt::format("Left type {} right type {} return type {}",
col_left.type->get_name(), col_right.type->get_name(),
return_type->get_name());
Expand Down Expand Up @@ -223,7 +223,7 @@ class FunctionEqForNull : public IFunction {
ColumnWithTypeAndName {col_right.column, col_right.type, ""}};
auto func_eq = SimpleFunctionFactory::instance().get_function(
"eq", eq_columns, return_type,
context ? context->state()->enable_decimal256() : false);
{.enable_decimal256 = context ? context->state()->enable_decimal256() : false});
DCHECK(func_eq);

Block temporary_block(eq_columns);
Expand Down
4 changes: 4 additions & 0 deletions be/src/vec/functions/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ struct FuncExprParams;

namespace doris::vectorized {

struct FunctionAttr {
bool enable_decimal256 {};
};

#define RETURN_REAL_TYPE_FOR_DATEV2_FUNCTION(TYPE) \
bool is_nullable = false; \
bool is_datev2 = false; \
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/functions/function_coalesce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FunctionCoalesce : public IFunction {
{nullptr, make_nullable(result_type), ""}};
func_is_not_null = SimpleFunctionFactory::instance().get_function(
"is_not_null_pred", is_not_null_col, std::make_shared<DataTypeUInt8>(),
context->state()->enable_decimal256());
{.enable_decimal256 = context->state()->enable_decimal256()});
}
DCHECK_GE(arguments.size(), 1);
DataTypePtr result_type = block.get_by_position(result).type;
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/functions/function_ifnull.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class FunctionIfNull : public IFunction {

auto func_if = SimpleFunctionFactory::instance().get_function(
"if", if_columns, block.get_by_position(result).type,
context->state()->enable_decimal256());
{.enable_decimal256 = context->state()->enable_decimal256()});
RETURN_IF_ERROR(func_if->execute(context, temporary_block, {0, 1, 2}, 3, input_rows_count));
block.get_by_position(result).column = temporary_block.get_by_position(3).column;
return Status::OK();
Expand Down
6 changes: 4 additions & 2 deletions be/src/vec/functions/nullif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class FunctionNullIf : public IFunction {
{nullptr, result_type, ""}});

auto equals_func = SimpleFunctionFactory::instance().get_function(
"eq", eq_columns, result_type, context->state()->enable_decimal256());
"eq", eq_columns, result_type,
{.enable_decimal256 = context->state()->enable_decimal256()});
DCHECK(equals_func);
RETURN_IF_ERROR(
equals_func->execute(context, eq_temporary_block, {0, 1}, 2, input_rows_count));
Expand Down Expand Up @@ -126,7 +127,8 @@ class FunctionNullIf : public IFunction {
new_result_column});

auto func_if = SimpleFunctionFactory::instance().get_function(
"if", if_columns, new_result_column.type, context->state()->enable_decimal256());
"if", if_columns, new_result_column.type,
{.enable_decimal256 = context->state()->enable_decimal256()});
DCHECK(func_if);
RETURN_IF_ERROR(func_if->execute(context, temporary_block, {0, 1, 2}, 3, input_rows_count));
block.get_by_position(result).column = temporary_block.get_by_position(3).column;
Expand Down
4 changes: 2 additions & 2 deletions be/src/vec/functions/simple_function_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ class SimpleFunctionFactory {
}

FunctionBasePtr get_function(const std::string& name, const ColumnsWithTypeAndName& arguments,
const DataTypePtr& return_type, bool enable_decimal256 = false,
const DataTypePtr& return_type, const FunctionAttr& attr = {},
int be_version = BeExecVersionManager::get_newest_version()) {
std::string key_str = name;

if (function_alias.contains(name)) {
key_str = function_alias[name];
}

if (enable_decimal256) {
if (attr.enable_decimal256) {
if (key_str == "array_sum" || key_str == "array_avg" || key_str == "array_product" ||
key_str == "array_cum_sum") {
key_str += DECIMAL256_FUNCTION_SUFFIX;
Expand Down

0 comments on commit d9c5c37

Please sign in to comment.