diff --git a/be/src/vec/exec/format/column_type_convert.h b/be/src/vec/exec/format/column_type_convert.h index 65742671f729cf..43cae065fca711 100644 --- a/be/src/vec/exec/format/column_type_convert.h +++ b/be/src/vec/exec/format/column_type_convert.h @@ -384,7 +384,7 @@ class CastStringConverter : public ColumnTypeConverter { to_col->resize(start_idx + rows); auto& data = static_cast(to_col.get())->get_data(); for (int i = 0; i < rows; ++i) { - DstCppType value; + DstCppType& value = data[start_idx + i]; auto string_value = string_col.get_data_at(i); bool can_cast = false; if constexpr (is_decimal_type_const()) { @@ -398,9 +398,7 @@ class CastStringConverter : public ColumnTypeConverter { can_cast = SafeCastString::safe_cast_string( string_value.data, string_value.size, &value); } - if (can_cast) { - data[start_idx + i] = value; - } else { + if (!can_cast) { if (null_map == nullptr) { return Status::InternalError("Failed to cast string '{}' to not null column", string_value.to_string());