jacktengg commented on code in PR #67981:
URL: https://github.com/apache/doris/pull/67981#discussion_r4022294161


##########
be/src/exprs/function/cast/cast_to_int.h:
##########
@@ -72,6 +72,11 @@ class CastToImpl<CastMode, FromDataType, ToDataType> : 
public CastToBase {
         CastParameters params;
         params.is_strict = (CastMode == CastModeType::StrictMode);
         for (size_t i = 0; i < input_rows_count; ++i) {
+            // The source value of a row marked as null by the input null map 
is a hidden
+            // payload and has no SQL semantics, so it must not be checked.
+            if (null_map && null_map[i]) {

Review Comment:
   fixed



##########
be/src/exprs/function/cast/cast_to_date.h:
##########
@@ -97,19 +97,45 @@ class CastToImpl<CastMode, FromDataType, ToDataType> : 
public CastToBase {
         if constexpr (CastMode == CastModeType::StrictMode) {
             MutableColumnPtr column_to = nested_to_type->create_column();
             // WON'T write nulls to the result column, just raise errors. 
null_map is only used to skip invalid rows
+            Status st;
             if constexpr (IsDataTypeInt<FromDataType>) {
-                RETURN_IF_ERROR(concrete_serde->template 
from_int_strict_mode_batch<FromDataType>(
-                        *col_from, *column_to));
+                st = concrete_serde->template 
from_int_strict_mode_batch<FromDataType>(*col_from,
+                                                                               
        *column_to);
             } else if constexpr (IsDataTypeFloat<FromDataType>) {
-                RETURN_IF_ERROR(concrete_serde->template 
from_float_strict_mode_batch<FromDataType>(
-                        *col_from, *column_to));
+                st = concrete_serde->template 
from_float_strict_mode_batch<FromDataType>(
+                        *col_from, *column_to);
             } else {
                 static_assert(IsDataTypeDecimal<FromDataType>);
-                RETURN_IF_ERROR(
-                        concrete_serde->template 
from_decimal_strict_mode_batch<FromDataType>(
-                                *col_from, *column_to));
+                st = concrete_serde->template 
from_decimal_strict_mode_batch<FromDataType>(
+                        *col_from, *column_to);
+            }
+            if (st.ok() || null_map == nullptr) {
+                RETURN_IF_ERROR(st);
+                block.get_by_position(result).column = std::move(column_to);
+            } else {
+                // The strict-mode serde batch cannot skip rows, so the 
failure may come from the
+                // hidden payload of a row that the input null map marks as 
NULL. Cast tolerantly
+                // and only report an error if a visible (non NULL) row 
failed; NULL rows are NULL
+                // in the final result anyway.
+                auto nullable_col_to = 
create_empty_nullable_column(nested_to_type);

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to