This is an automated email from the ASF dual-hosted git repository. lihaopeng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new c2af14fc61 [Bug] return type is not always nullable of function (#10116) c2af14fc61 is described below commit c2af14fc611b22267268fb944039dc6772a4d825 Author: HappenLee <happen...@hotmail.com> AuthorDate: Tue Jun 14 16:32:35 2022 +0800 [Bug] return type is not always nullable of function (#10116) Co-authored-by: lihaopeng <lihaop...@baidu.com> --- be/src/udf/udf.cpp | 2 -- be/src/vec/functions/nullif.cpp | 21 +++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/be/src/udf/udf.cpp b/be/src/udf/udf.cpp index f7491d4c5e..7dac939fd7 100644 --- a/be/src/udf/udf.cpp +++ b/be/src/udf/udf.cpp @@ -542,10 +542,8 @@ void* FunctionContext::get_function_state(FunctionStateScope scope) const { switch (scope) { case THREAD_LOCAL: return _impl->_thread_local_fn_state; - break; case FRAGMENT_LOCAL: return _impl->_fragment_local_fn_state; - break; default: // TODO: signal error somehow return nullptr; diff --git a/be/src/vec/functions/nullif.cpp b/be/src/vec/functions/nullif.cpp index 43ad488841..9b1da5939c 100644 --- a/be/src/vec/functions/nullif.cpp +++ b/be/src/vec/functions/nullif.cpp @@ -50,7 +50,7 @@ public: bool use_default_implementation_for_nulls() const override { return false; } DataTypePtr get_return_type_impl(const DataTypes& arguments) const override { - return arguments[0]; + return make_nullable(arguments[0]); } NullPresence get_null_resense(const ColumnsWithTypeAndName& args) const { @@ -103,7 +103,9 @@ public: auto equals_func = SimpleFunctionFactory::instance().get_function("eq", eq_columns, result_type); - equals_func->execute(context, eq_temporary_block, {0, 1}, 2, input_rows_count); + DCHECK(equals_func); + RETURN_IF_ERROR( + equals_func->execute(context, eq_temporary_block, {0, 1}, 2, input_rows_count)); const ColumnWithTypeAndName new_result_column { block.get_by_position(result), @@ -127,18 +129,13 @@ public: block.get_by_position(result).type, "NULL"}, block.get_by_position(arguments[0]), new_result_column}); + auto func_if = SimpleFunctionFactory::instance().get_function("if", if_columns, new_result_column.type); - func_if->execute(context, temporary_block, {0, 1, 2}, 3, input_rows_count); - /// need to handle nullable type and not nullable type differently, - /// because `IF` function always return nullable type, but result type is not always - if (block.get_by_position(result).type->is_nullable()) { - block.get_by_position(result).column = temporary_block.get_by_position(3).column; - } else { - auto cols = check_and_get_column<ColumnNullable>( - temporary_block.get_by_position(3).column.get()); - block.replace_by_position(result, std::move(cols->get_nested_column_ptr())); - } + 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; + return Status::OK(); } }; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org