[Bug](function) fix function in get wrong result when input const column (#19791)
fix function in get wrong result when input const column
This commit is contained in:
@ -50,10 +50,10 @@ class TExprNode;
|
||||
|
||||
namespace doris::vectorized {
|
||||
|
||||
VectorizedFnCall::VectorizedFnCall(const doris::TExprNode& node) : VExpr(node) {}
|
||||
VectorizedFnCall::VectorizedFnCall(const TExprNode& node) : VExpr(node) {}
|
||||
|
||||
doris::Status VectorizedFnCall::prepare(doris::RuntimeState* state,
|
||||
const doris::RowDescriptor& desc, VExprContext* context) {
|
||||
Status VectorizedFnCall::prepare(RuntimeState* state, const RowDescriptor& desc,
|
||||
VExprContext* context) {
|
||||
RETURN_IF_ERROR_OR_PREPARED(VExpr::prepare(state, desc, context));
|
||||
ColumnsWithTypeAndName argument_template;
|
||||
argument_template.reserve(_children.size());
|
||||
@ -89,33 +89,36 @@ doris::Status VectorizedFnCall::prepare(doris::RuntimeState* state,
|
||||
}
|
||||
VExpr::register_function_context(state, context);
|
||||
_expr_name = fmt::format("{}({})", _fn.name.function_name, child_expr_name);
|
||||
_function_name = _fn.name.function_name;
|
||||
_can_fast_execute = _function->can_fast_execute();
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
doris::Status VectorizedFnCall::open(doris::RuntimeState* state, VExprContext* context,
|
||||
FunctionContext::FunctionStateScope scope) {
|
||||
Status VectorizedFnCall::open(RuntimeState* state, VExprContext* context,
|
||||
FunctionContext::FunctionStateScope scope) {
|
||||
RETURN_IF_ERROR(VExpr::open(state, context, scope));
|
||||
RETURN_IF_ERROR(VExpr::init_function_context(context, scope, _function));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
void VectorizedFnCall::close(doris::RuntimeState* state, VExprContext* context,
|
||||
void VectorizedFnCall::close(RuntimeState* state, VExprContext* context,
|
||||
FunctionContext::FunctionStateScope scope) {
|
||||
VExpr::close_function_context(context, scope, _function);
|
||||
VExpr::close(state, context, scope);
|
||||
}
|
||||
|
||||
doris::Status VectorizedFnCall::execute(VExprContext* context, doris::vectorized::Block* block,
|
||||
int* result_column_id) {
|
||||
Status VectorizedFnCall::execute(VExprContext* context, vectorized::Block* block,
|
||||
int* result_column_id) {
|
||||
// TODO: not execute const expr again, but use the const column in function context
|
||||
doris::vectorized::ColumnNumbers arguments(_children.size());
|
||||
vectorized::ColumnNumbers arguments(_children.size());
|
||||
for (int i = 0; i < _children.size(); ++i) {
|
||||
int column_id = -1;
|
||||
RETURN_IF_ERROR(_children[i]->execute(context, block, &column_id));
|
||||
arguments[i] = column_id;
|
||||
}
|
||||
RETURN_IF_ERROR(check_constant(*block, arguments));
|
||||
|
||||
// call function
|
||||
size_t num_columns_without_result = block->columns();
|
||||
// prepare a column to save result
|
||||
@ -133,6 +136,7 @@ doris::Status VectorizedFnCall::execute(VExprContext* context, doris::vectorized
|
||||
RETURN_IF_ERROR(_function->execute(context->fn_context(_fn_context_index), *block, arguments,
|
||||
num_columns_without_result, block->rows(), false));
|
||||
*result_column_id = num_columns_without_result;
|
||||
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user