This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new d466e0b84a [branch-1.2](cherry-pick) using typeindex to create column instead of type name because type name is not stable (#19004) d466e0b84a is described below commit d466e0b84a1075be382fc37cbc148aa166abd597 Author: yiguolei <676222...@qq.com> AuthorDate: Mon Apr 24 20:31:14 2023 +0800 [branch-1.2](cherry-pick) using typeindex to create column instead of type name because type name is not stable (#19004) Co-authored-by: yiguolei <yiguo...@gmail.com> --- be/src/vec/exprs/vcast_expr.cpp | 6 +++--- be/src/vec/functions/function_cast.h | 11 ++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/be/src/vec/exprs/vcast_expr.cpp b/be/src/vec/exprs/vcast_expr.cpp index 68f3b05cc1..6d8d194e73 100644 --- a/be/src/vec/exprs/vcast_expr.cpp +++ b/be/src/vec/exprs/vcast_expr.cpp @@ -38,9 +38,9 @@ doris::Status VCastExpr::prepare(doris::RuntimeState* state, const doris::RowDes // create a const string column _target_data_type = _data_type; - _target_data_type_name = DataTypeFactory::instance().get(_target_data_type); - _cast_param_data_type = std::make_shared<DataTypeString>(); - _cast_param = _cast_param_data_type->create_column_const(1, _target_data_type_name); + _target_data_type_name = _target_data_type->get_name(); + _cast_param_data_type = _target_data_type; + _cast_param = _cast_param_data_type->create_column_const_with_default_value(1); ColumnsWithTypeAndName argument_template; argument_template.reserve(2); diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h index 59f58be84c..aa9fbc9fba 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -1750,14 +1750,7 @@ protected: } DataTypePtr get_return_type_impl(const ColumnsWithTypeAndName& arguments) const override { - const auto type_col = - check_and_get_column_const<ColumnString>(arguments.back().column.get()); - if (!type_col) { - LOG(FATAL) << fmt::format( - "Second argument to {} must be a constant string describing type", get_name()); - } - auto type = DataTypeFactory::instance().get(type_col->get_value<String>()); - DCHECK(type != nullptr); + DataTypePtr type = arguments[1].type; bool need_to_be_nullable = false; // 1. from_type is nullable @@ -1775,7 +1768,7 @@ protected: arguments[0].type->get_type_id() != TypeIndex::DateTimeV2) && (type->get_type_id() == TypeIndex::DateV2 || type->get_type_id() == TypeIndex::DateTimeV2); - if (need_to_be_nullable) { + if (need_to_be_nullable && !type->is_nullable()) { return make_nullable(type); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org