Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions be/src/vec/exprs/vcast_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 2 additions & 9 deletions be/src/vec/functions/function_cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -1750,14 +1750,7 @@ class FunctionBuilderCast : public FunctionBuilderImpl {
}

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
Expand All @@ -1775,7 +1768,7 @@ class FunctionBuilderCast : public FunctionBuilderImpl {
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);
}

Expand Down