This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new d5fd1b68aad branch-4.0: [Refactor](cast) Make all nullable for cast 
from string to simple types #57949 (#58924)
d5fd1b68aad is described below

commit d5fd1b68aad68149a99fd71b8e3d0a5032d27b6e
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Dec 11 19:19:06 2025 +0800

    branch-4.0: [Refactor](cast) Make all nullable for cast from string to 
simple types #57949 (#58924)
    
    Cherry-picked from #57949
    
    Co-authored-by: zclllyybb <[email protected]>
---
 .../data_types/serde/data_type_nullable_serde.cpp  | 10 ++-
 be/src/vec/functions/cast/cast_base.cpp            | 18 ++++-
 .../functions/cast/cast_to_basic_number_common.h   | 26 ++++---
 be/src/vec/functions/cast/cast_to_boolean.h        | 26 +++----
 be/src/vec/functions/cast/cast_to_date.h           | 67 +++++++++---------
 be/src/vec/functions/cast/cast_to_decimal.h        | 80 ++++++++++------------
 be/src/vec/functions/cast/cast_to_float.h          |  2 +-
 be/src/vec/functions/cast/cast_to_int.h            | 37 +++++-----
 be/src/vec/functions/cast/cast_to_ip.h             | 25 +++----
 be/src/vec/functions/cast/cast_to_jsonb.h          |  9 ++-
 be/test/vec/function/cast/cast_to_integer.cpp      |  7 +-
 .../doris/nereids/trees/expressions/Cast.java      | 13 ----
 .../trees/expressions/functions/scalar/Date.java   |  1 +
 .../cast/test_cast_to_complex_types_strict.groovy  |  6 ++
 .../suites/prepared_stmt_p0/prepared_stmt.groovy   | 31 ++++-----
 15 files changed, 170 insertions(+), 188 deletions(-)

diff --git a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp 
b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
index 1668cbfcf88..96b034955a3 100644
--- a/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_nullable_serde.cpp
@@ -36,9 +36,7 @@
 #include "vec/functions/cast/cast_base.h"
 #include "vec/runtime/vcsv_transformer.h"
 
-namespace doris {
-
-namespace vectorized {
+namespace doris::vectorized {
 class Arena;
 #include "common/compile_check_begin.h"
 Status DataTypeNullableSerDe::serialize_column_to_json(const IColumn& column, 
int64_t start_idx,
@@ -489,10 +487,10 @@ Status DataTypeNullableSerDe::from_string(StringRef& str, 
IColumn& column,
 Status DataTypeNullableSerDe::from_string_strict_mode(StringRef& str, IColumn& 
column,
                                                       const FormatOptions& 
options) const {
     auto& null_column = assert_cast<ColumnNullable&>(column);
-    RETURN_IF_ERROR(nested_serde->from_string(str, 
null_column.get_nested_column(), options));
+    RETURN_IF_ERROR(
+            nested_serde->from_string_strict_mode(str, 
null_column.get_nested_column(), options));
     // fill not null if success
     null_column.get_null_map_data().push_back(0);
     return Status::OK();
 }
-} // namespace vectorized
-} // namespace doris
+} // namespace doris::vectorized
diff --git a/be/src/vec/functions/cast/cast_base.cpp 
b/be/src/vec/functions/cast/cast_base.cpp
index 325863276c4..f198823206a 100644
--- a/be/src/vec/functions/cast/cast_base.cpp
+++ b/be/src/vec/functions/cast/cast_base.cpp
@@ -161,6 +161,8 @@ WrapperType create_identity_wrapper(const DataTypePtr&) {
     };
 }
 
+/// the only difference between these two functions is throw error or not when 
parsing fail.
+/// the return columns are both nullable columns.
 Status cast_from_string_to_complex_type(FunctionContext* context, Block& block,
                                         const ColumnNumbers& arguments, 
uint32_t result,
                                         size_t input_rows_count,
@@ -170,13 +172,17 @@ Status cast_from_string_to_complex_type(FunctionContext* 
context, Block& block,
 
     auto to_type = block.get_by_position(result).type;
     auto to_serde = remove_nullable(to_type)->get_serde();
+
+    // string to complex type is always nullable
     MutableColumnPtr to_column = make_nullable(to_type)->create_column();
     auto& nullable_col_to = assert_cast<ColumnNullable&>(*to_column);
     auto& nested_column = nullable_col_to.get_nested_column();
+
     DataTypeSerDe::FormatOptions options;
     options.converted_from_string = true;
     options.escape_char = '\\';
     options.timezone = &context->state()->timezone_obj();
+
     for (size_t i = 0; i < input_rows_count; ++i) {
         if (null_map && null_map[i]) {
             nullable_col_to.insert_default();
@@ -204,17 +210,25 @@ Status 
cast_from_string_to_complex_type_strict_mode(FunctionContext* context, Bl
 
     auto to_type = block.get_by_position(result).type;
     auto to_serde = remove_nullable(to_type)->get_serde();
-    MutableColumnPtr to_column = remove_nullable(to_type)->create_column();
+
+    // string to complex type is always nullable
+    MutableColumnPtr to_column = make_nullable(to_type)->create_column();
+    auto& nullable_col_to = assert_cast<ColumnNullable&>(*to_column);
+    auto& nested_column = nullable_col_to.get_nested_column();
+
     DataTypeSerDe::FormatOptions options;
     options.converted_from_string = true;
     options.escape_char = '\\';
     options.timezone = &context->state()->timezone_obj();
+
     for (size_t i = 0; i < input_rows_count; ++i) {
         if (null_map && null_map[i]) {
             to_column->insert_default();
         } else {
             auto str = col_from->get_data_at(i);
-            RETURN_IF_ERROR(to_serde->from_string_strict_mode(str, *to_column, 
options));
+            RETURN_IF_ERROR(to_serde->from_string_strict_mode(str, 
nested_column, options));
+            // fill not null if success
+            nullable_col_to.get_null_map_data().push_back(0);
         }
     }
     block.get_by_position(result).column = std::move(to_column);
diff --git a/be/src/vec/functions/cast/cast_to_basic_number_common.h 
b/be/src/vec/functions/cast/cast_to_basic_number_common.h
index 001aa905b2d..ff597d238ad 100644
--- a/be/src/vec/functions/cast/cast_to_basic_number_common.h
+++ b/be/src/vec/functions/cast/cast_to_basic_number_common.h
@@ -24,6 +24,7 @@
 #include "common/status.h"
 #include "runtime/define_primitive_type.h"
 #include "runtime/primitive_type.h"
+#include "vec/columns/column_nullable.h"
 #include "vec/core/types.h"
 #include "vec/data_types/data_type_decimal.h"
 #include "vec/data_types/data_type_number.h"
@@ -442,30 +443,27 @@ class CastToImpl<Mode, DataTypeString, ToDataType> : 
public CastToBase {
                 block.get_by_position(arguments[0]).column.get());
         auto to_type = block.get_by_position(result).type;
         auto serde = remove_nullable(to_type)->get_serde();
-        MutableColumnPtr column_to;
+
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
 
         DataTypeSerDe::FormatOptions format_options;
         format_options.converted_from_string = true;
 
         if constexpr (Mode == CastModeType::NonStrictMode) {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
nullable_col_to, format_options));
+            // may write nulls to nullable_col_to
+            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
*nullable_col_to, format_options));
         } else if constexpr (Mode == CastModeType::StrictMode) {
-            if (to_type->is_nullable()) {
-                return Status::InternalError(
-                        "result type should be not nullable when casting 
string to number in "
-                        "strict cast mode");
-            }
-            column_to = to_type->create_column();
-            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(*col_from, 
*column_to,
-                                                                 
format_options, null_map));
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
+            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
+                    *col_from, nullable_col_to->get_nested_column(), 
format_options, null_map));
         } else {
             return Status::InternalError("Unsupported cast mode");
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
diff --git a/be/src/vec/functions/cast/cast_to_boolean.h 
b/be/src/vec/functions/cast/cast_to_boolean.h
index e89d5ff1ab1..cce2926f8f2 100644
--- a/be/src/vec/functions/cast/cast_to_boolean.h
+++ b/be/src/vec/functions/cast/cast_to_boolean.h
@@ -124,30 +124,26 @@ public:
                         const NullMap::value_type* null_map = nullptr) const 
override {
         const auto* col_from = 
check_and_get_column<DataTypeString::ColumnType>(
                 block.get_by_position(arguments[0]).column.get());
-
         auto to_type = block.get_by_position(result).type;
         auto serde = remove_nullable(to_type)->get_serde();
-        MutableColumnPtr column_to;
+
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
 
         if constexpr (Mode == CastModeType::NonStrictMode) {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
nullable_col_to, {}));
+            // may write nulls to nullable_col_to
+            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
*nullable_col_to, {}));
         } else if constexpr (Mode == CastModeType::StrictMode) {
-            if (to_type->is_nullable()) {
-                return Status::InternalError(
-                        "result type should be not nullable when casting 
string to boolean in "
-                        "strict cast mode");
-            }
-            column_to = to_type->create_column();
-            RETURN_IF_ERROR(
-                    serde->from_string_strict_mode_batch(*col_from, 
*column_to, {}, null_map));
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
+            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
+                    *col_from, nullable_col_to->get_nested_column(), {}, 
null_map));
         } else {
             return Status::InternalError("Unsupported cast mode");
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
diff --git a/be/src/vec/functions/cast/cast_to_date.h 
b/be/src/vec/functions/cast/cast_to_date.h
index 243bd19f179..428b3963ddb 100644
--- a/be/src/vec/functions/cast/cast_to_date.h
+++ b/be/src/vec/functions/cast/cast_to_date.h
@@ -54,25 +54,25 @@ public:
 
         auto to_type = block.get_by_position(result).type;
         auto serde = remove_nullable(to_type)->get_serde();
-        MutableColumnPtr column_to;
 
         DataTypeSerDe::FormatOptions options;
         options.timezone = &context->state()->timezone_obj();
 
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
+
         if constexpr (CastMode == CastModeType::StrictMode) {
-            DCHECK(!to_type->is_nullable()) << "shouldn't be extra nullable 
here. if argument is "
-                                               "null, should be processed in 
framework.";
-            column_to = to_type->create_column();
-            RETURN_IF_ERROR(
-                    serde->from_string_strict_mode_batch(*col_from, 
*column_to, options, null_map));
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
+            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
+                    *col_from, nullable_col_to->get_nested_column(), options, 
null_map));
         } else {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
nullable_col_to, options));
+            // may write nulls to nullable_col_to
+            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
*nullable_col_to, options));
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
@@ -86,50 +86,47 @@ public:
                         const NullMap::value_type* null_map = nullptr) const 
override {
         const auto* col_from = check_and_get_column<typename 
FromDataType::ColumnType>(
                 block.get_by_position(arguments[0]).column.get());
-
         auto to_type = block.get_by_position(result).type;
         auto concrete_serde = std::dynamic_pointer_cast<typename 
ToDataType::SerDeType>(
                 remove_nullable(to_type)->get_serde());
-        MutableColumnPtr column_to;
 
-        if constexpr (CastMode == CastModeType::StrictMode) {
-            DCHECK(!to_type->is_nullable()) << "shouldn't be extra nullable 
here. if argument is "
-                                               "null, should be processed in 
framework.";
-            column_to = to_type->create_column();
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
 
-            // datelike types serde must have template functions for those 
types. but because of they need to be
-            // template functions, so we cannot make them virtual. that's why 
we assert_cast `serde` before.
+        // datelike types serde must have template functions for those types. 
but because of they need to be
+        // template functions, so we cannot make them virtual. that's why we 
assert_cast `serde` before.
+        if constexpr (CastMode == CastModeType::StrictMode) {
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
             if constexpr (IsDataTypeInt<FromDataType>) {
                 RETURN_IF_ERROR(concrete_serde->template 
from_int_strict_mode_batch<FromDataType>(
-                        *col_from, *column_to));
+                        *col_from, nullable_col_to->get_nested_column()));
             } else if constexpr (IsDataTypeFloat<FromDataType>) {
                 RETURN_IF_ERROR(concrete_serde->template 
from_float_strict_mode_batch<FromDataType>(
-                        *col_from, *column_to));
+                        *col_from, nullable_col_to->get_nested_column()));
             } else {
                 static_assert(IsDataTypeDecimal<FromDataType>);
                 RETURN_IF_ERROR(
                         concrete_serde->template 
from_decimal_strict_mode_batch<FromDataType>(
-                                *col_from, *column_to));
+                                *col_from, 
nullable_col_to->get_nested_column()));
             }
         } else {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-
+            // may write nulls to nullable_col_to
             if constexpr (IsDataTypeInt<FromDataType>) {
                 RETURN_IF_ERROR(concrete_serde->template 
from_int_batch<FromDataType>(
-                        *col_from, nullable_col_to));
+                        *col_from, *nullable_col_to));
             } else if constexpr (IsDataTypeFloat<FromDataType>) {
                 RETURN_IF_ERROR(concrete_serde->template 
from_float_batch<FromDataType>(
-                        *col_from, nullable_col_to));
+                        *col_from, *nullable_col_to));
             } else {
                 static_assert(IsDataTypeDecimal<FromDataType>);
                 RETURN_IF_ERROR(concrete_serde->template 
from_decimal_batch<FromDataType>(
-                        *col_from, nullable_col_to));
+                        *col_from, *nullable_col_to));
             }
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
@@ -141,10 +138,8 @@ public:
     Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
                         uint32_t result, size_t input_rows_count,
                         const NullMap::value_type* null_map = nullptr) const 
override {
-        constexpr bool Nullable =
-                std::is_same_v<FromDataType, ToDataType> &&
-                (IsTimeV2Type<FromDataType> || 
IsDateTimeV2Type<FromDataType>)&&CastMode ==
-                        CastModeType::NonStrictMode;
+        constexpr bool Nullable = std::is_same_v<FromDataType, ToDataType> &&
+                                  (IsTimeV2Type<FromDataType> || 
IsDateTimeV2Type<FromDataType>);
 
         const auto* col_from = check_and_get_column<typename 
FromDataType::ColumnType>(
                 block.get_by_position(arguments[0]).column.get());
@@ -295,7 +290,7 @@ public:
                     uint32_t microseconds = dtmv2.microsecond();
                     DCHECK(to_scale <= 6)
                             << "to_scale should be in range [0, 6], but got " 
<< to_scale;
-                    uint32_t divisor = (uint32_t)common::exp10_i64(6 - 
to_scale);
+                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
                     uint32_t remainder = microseconds % divisor;
 
                     if (remainder >= divisor / 2) { // need to round up
@@ -400,7 +395,7 @@ public:
                     // 999956: 56 > 100/2, then round up to 1000000
                     DCHECK(to_scale <= 6)
                             << "to_scale should be in range [0, 6], but got " 
<< to_scale;
-                    uint32_t divisor = (uint32_t)common::exp10_i64(6 - 
to_scale);
+                    auto divisor = (uint32_t)common::exp10_i64(6 - to_scale);
                     uint32_t remainder = microseconds % divisor;
                     microseconds = (microseconds / divisor) * divisor;
                     if (remainder >= divisor / 2) {
diff --git a/be/src/vec/functions/cast/cast_to_decimal.h 
b/be/src/vec/functions/cast/cast_to_decimal.h
index b464bb43b0b..330886f093c 100644
--- a/be/src/vec/functions/cast/cast_to_decimal.h
+++ b/be/src/vec/functions/cast/cast_to_decimal.h
@@ -491,32 +491,29 @@ class CastToImpl<Mode, DataTypeString, ToDataType> : 
public CastToBase {
 
         auto to_type = block.get_by_position(result).type;
         auto serde = remove_nullable(to_type)->get_serde();
-        MutableColumnPtr column_to;
+
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
 
         if constexpr (Mode == CastModeType::NonStrictMode) {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
nullable_col_to, {}));
+            // may write nulls to nullable_col_to
+            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
*nullable_col_to, {}));
         } else if constexpr (Mode == CastModeType::StrictMode) {
-            if (to_type->is_nullable()) {
-                return Status::InternalError(
-                        "result type should be not nullable when casting 
string to decimal in "
-                        "strict cast mode");
-            }
-            column_to = to_type->create_column();
-            RETURN_IF_ERROR(
-                    serde->from_string_strict_mode_batch(*col_from, 
*column_to, {}, null_map));
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
+            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
+                    *col_from, nullable_col_to->get_nested_column(), {}, 
null_map));
         } else {
             return Status::InternalError("Unsupported cast mode");
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
 
-// cast bool and int to decimal
+// cast bool and int to decimal. when may overflow, result column is nullable.
 template <CastModeType CastMode, typename FromDataType, typename ToDataType>
     requires(IsDataTypeDecimal<ToDataType> &&
              (IsDataTypeInt<FromDataType> || IsDataTypeBool<FromDataType>))
@@ -547,8 +544,10 @@ public:
 
         auto from_max_int_digit_count = from_precision - from_scale;
         auto to_max_int_digit_count = to_precision - to_scale;
+        // may overflow. nullable result column.
         bool narrow_integral = (to_max_int_digit_count < 
from_max_int_digit_count);
-        bool result_is_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
+        // only in non-strict mode and may overflow, we set nullable
+        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
 
         constexpr UInt32 to_max_digits =
                 NumberTraits::max_ascii_len<typename 
ToFieldType::NativeType>();
@@ -567,7 +566,7 @@ public:
 
         ColumnUInt8::MutablePtr col_null_map_to;
         NullMap::value_type* null_map_data = nullptr;
-        if (result_is_nullable) {
+        if (narrow_integral) {
             col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
             null_map_data = col_null_map_to->get_data().data();
         }
@@ -590,7 +589,7 @@ public:
                                                       multiply_may_overflow, 
narrow_integral>(
                                     vec_from_data[i], vec_to_data[i], 
to_precision, to_scale,
                                     scale_multiplier, min_result, max_result, 
params)) {
-                            if (result_is_nullable) {
+                            if (set_nullable) {
                                 null_map_data[i] = 1;
                             } else {
                                 return params.status;
@@ -601,7 +600,7 @@ public:
                 },
                 make_bool_variant(multiply_may_overflow), 
make_bool_variant(narrow_integral)));
 
-        if (result_is_nullable) {
+        if (narrow_integral) {
             block.get_by_position(result).column =
                     ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
         } else {
@@ -611,7 +610,7 @@ public:
     }
 };
 
-// cast float and double to decimal
+// cast float and double to decimal. ALWAYS nullable result column.
 template <CastModeType CastMode, typename FromDataType, typename ToDataType>
     requires(IsDataTypeDecimal<ToDataType> && IsDataTypeFloat<FromDataType>)
 class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
@@ -644,14 +643,11 @@ public:
         bool narrow_integral =
                 (to_max_int_digit_count < from_max_int_digit_count) ||
                 (to_max_int_digit_count == from_max_int_digit_count && 
to_scale < from_scale);
-        bool result_is_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
+        // only in non-strict mode and may overflow, we set nullable
+        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
 
-        ColumnUInt8::MutablePtr col_null_map_to;
-        NullMap::value_type* null_map_data = nullptr;
-        if (result_is_nullable) {
-            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
-            null_map_data = col_null_map_to->get_data().data();
-        }
+        ColumnUInt8::MutablePtr col_null_map_to = 
ColumnUInt8::create(input_rows_count, 0);
+        NullMap::value_type* null_map_data = 
col_null_map_to->get_data().data();
 
         auto col_to = ToDataType::ColumnType::create(input_rows_count, 
to_scale);
         const auto& vec_from = col_from->get_data();
@@ -673,7 +669,7 @@ public:
                                             typename ToDataType::FieldType>(
                         vec_from_data[i], vec_to_data[i], to_precision, 
to_scale, scale_multiplier,
                         min_result, max_result, params)) {
-                if (result_is_nullable) {
+                if (set_nullable) {
                     null_map_data[i] = 1;
                 } else {
                     return params.status;
@@ -681,12 +677,8 @@ public:
             }
         }
 
-        if (result_is_nullable) {
-            block.get_by_position(result).column =
-                    ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
-        } else {
-            block.get_by_position(result).column = std::move(col_to);
-        }
+        block.get_by_position(result).column =
+                ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
         return Status::OK();
     }
 };
@@ -742,13 +734,13 @@ public:
         bool narrow_integral = (to_max_int_digit_count < 
from_max_int_digit_count) ||
                                (to_max_int_digit_count == 
from_max_int_digit_count &&
                                 to_scale < from_original_scale);
-
-        bool result_is_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
+        // only in non-strict mode and may overflow, we set nullable
+        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
 
         size_t size = col_from->size();
         ColumnUInt8::MutablePtr col_null_map_to;
         NullMap::value_type* null_map_data = nullptr;
-        if (result_is_nullable) {
+        if (narrow_integral) {
             col_null_map_to = ColumnUInt8::create(size, 0);
             null_map_data = col_null_map_to->get_data().data();
         }
@@ -796,7 +788,7 @@ public:
                                     vec_from_data[i], from_precision, 
from_scale, vec_to_data[i],
                                     to_precision, to_scale, min_result, 
max_result, multiplier,
                                     params)) {
-                            if (result_is_nullable) {
+                            if (set_nullable) {
                                 null_map_data[i] = 1;
                             } else {
                                 return params.status;
@@ -806,7 +798,7 @@ public:
                     return Status::OK();
                 },
                 make_bool_variant(multiply_may_overflow), 
make_bool_variant(narrow_integral)));
-        if (result_is_nullable) {
+        if (narrow_integral) {
             block.get_by_position(result).column =
                     ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
         } else {
@@ -850,13 +842,13 @@ public:
         bool narrow_integral =
                 (to_max_int_digit_count < from_max_int_digit_count) ||
                 (to_max_int_digit_count == from_max_int_digit_count && 
to_scale < from_scale);
-
-        bool result_is_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
+        // only in non-strict mode and may overflow, we set nullable
+        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && 
narrow_integral;
 
         size_t size = col_from->size();
         ColumnUInt8::MutablePtr col_null_map_to;
         NullMap::value_type* null_map_data = nullptr;
-        if (result_is_nullable) {
+        if (narrow_integral) {
             col_null_map_to = ColumnUInt8::create(size, 0);
             null_map_data = col_null_map_to->get_data().data();
         }
@@ -903,7 +895,7 @@ public:
                                     vec_from_data[i], from_precision, 
from_scale, vec_to_data[i],
                                     to_precision, to_scale, min_result, 
max_result, multiplier,
                                     params)) {
-                            if (result_is_nullable) {
+                            if (set_nullable) {
                                 null_map_data[i] = 1;
                             } else {
                                 return params.status;
@@ -913,7 +905,7 @@ public:
                     return Status::OK();
                 },
                 make_bool_variant(multiply_may_overflow), 
make_bool_variant(narrow_integral)));
-        if (result_is_nullable) {
+        if (narrow_integral) {
             block.get_by_position(result).column =
                     ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
         } else {
diff --git a/be/src/vec/functions/cast/cast_to_float.h 
b/be/src/vec/functions/cast/cast_to_float.h
index c24f4a70710..a751f0123cd 100644
--- a/be/src/vec/functions/cast/cast_to_float.h
+++ b/be/src/vec/functions/cast/cast_to_float.h
@@ -82,7 +82,7 @@ public:
 };
 
 // cast date and datetime to float/double, will not overflow
-// only support in non-strict mode
+// only support in non-strict mode. strict mode it's illegal!
 template <typename FromDataType, typename ToDataType>
     requires(IsDataTypeFloat<ToDataType> &&
              (IsDatelikeV1Types<FromDataType> || 
IsDatelikeV2Types<FromDataType> ||
diff --git a/be/src/vec/functions/cast/cast_to_int.h 
b/be/src/vec/functions/cast/cast_to_int.h
index a1a84b4f0de..cdb7a6709af 100644
--- a/be/src/vec/functions/cast/cast_to_int.h
+++ b/be/src/vec/functions/cast/cast_to_int.h
@@ -17,7 +17,6 @@
 
 #pragma once
 
-#include <cmath>
 #include <type_traits>
 
 #include "cast_to_basic_number_common.h"
@@ -47,6 +46,7 @@ constexpr bool CastToIntMayOverflow =
          (std::is_same_v<ToDataType, DataTypeInt32> || 
std::is_same_v<ToDataType, DataTypeInt16> ||
           std::is_same_v<ToDataType, DataTypeInt8>));
 
+// from number types and timev2 type to integer types which this cast may 
overflow -> result type is always nullable.
 template <CastModeType CastMode, typename FromDataType, typename ToDataType>
     requires(IsDataTypeInt<ToDataType> &&
              (IsDataTypeNumber<FromDataType> || std::is_same_v<FromDataType, 
DataTypeTimeV2>) &&
@@ -67,18 +67,15 @@ public:
         auto col_to = ToDataType::ColumnType::create(input_rows_count);
         const auto& vec_from = col_from->get_data();
         auto& vec_to = col_to->get_data();
-        constexpr bool result_is_nullable = (CastMode == 
CastModeType::NonStrictMode);
-        ColumnUInt8::MutablePtr col_null_map_to;
-        NullMap::value_type* vec_null_map_to = nullptr;
-        if constexpr (result_is_nullable) {
-            col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
-            vec_null_map_to = col_null_map_to->get_data().data();
-        }
+        ColumnBool::MutablePtr col_null_map_to = 
ColumnBool::create(input_rows_count, 0);
+        NullMap::value_type* vec_null_map_to = 
col_null_map_to->get_data().data();
 
         CastParameters params;
         params.is_strict = (CastMode == CastModeType::StrictMode);
         for (size_t i = 0; i < input_rows_count; ++i) {
             if constexpr (IsDataTypeInt<FromDataType>) {
+                // although always nullable output, but only set null when 
overflow in non-strict mode.
+                // in strict mode, just raise error on overflow.
                 if (!CastToInt::from_int(vec_from[i], vec_to[i], params)) {
                     if constexpr (CastMode == CastModeType::NonStrictMode) {
                         vec_null_map_to[i] = 1;
@@ -111,18 +108,14 @@ public:
                                                          
type_to_string(ToDataType::PType)));
             }
         }
-        if constexpr (result_is_nullable) {
-            block.get_by_position(result).column =
-                    ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
-        } else {
-            block.get_by_position(result).column = std::move(col_to);
-        }
+        block.get_by_position(result).column =
+                ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
 
         return Status::OK();
     }
 };
 
-/// cast to int, will not overflow:
+/// cast to int, will not overflow and no nullable output:
 /// 1. from bool;
 /// 2. from narrow int to wider int
 /// 3. from time to bigint and largeint
@@ -140,7 +133,7 @@ public:
     }
 };
 
-// cast decimal to integer
+// cast decimal to integer. always use overflow check to decide nullable
 template <CastModeType CastMode, typename FromDataType, typename ToDataType>
     requires(IsDataTypeInt<ToDataType> && IsDataTypeDecimal<FromDataType>)
 class CastToImpl<CastMode, FromDataType, ToDataType> : public CastToBase {
@@ -167,8 +160,10 @@ public:
         bool narrow_integral = (from_precision - from_scale) >= to_max_digits;
 
         // may overflow if integer part of decimal is larger than to_max_digits
-        bool may_overflow = (from_precision - from_scale) >= to_max_digits;
-        bool result_is_nullable = (CastMode == CastModeType::NonStrictMode) && 
may_overflow;
+        // in strict mode we also decide nullable on this.
+        bool overflow_and_nullable = (from_precision - from_scale) >= 
to_max_digits;
+        // only in non-strict mode and may overflow, we set nullable
+        bool set_nullable = (CastMode == CastModeType::NonStrictMode) && 
overflow_and_nullable;
 
         auto col_to = ToDataType::ColumnType::create(input_rows_count);
         const auto& vec_from = col_from->get_data();
@@ -178,7 +173,7 @@ public:
 
         ColumnUInt8::MutablePtr col_null_map_to;
         NullMap::value_type* null_map_data = nullptr;
-        if (result_is_nullable) {
+        if (overflow_and_nullable) {
             col_null_map_to = ColumnUInt8::create(input_rows_count, 0);
             null_map_data = col_null_map_to->get_data().data();
         }
@@ -193,7 +188,7 @@ public:
                                           typename ToDataType::FieldType>(
                         vec_from_data[i], from_precision, from_scale, 
vec_to_data[i],
                         scale_multiplier, narrow_integral, params)) {
-                if (result_is_nullable) {
+                if (set_nullable) {
                     null_map_data[i] = 1;
                 } else {
                     return params.status;
@@ -201,7 +196,7 @@ public:
             }
         }
 
-        if (result_is_nullable) {
+        if (overflow_and_nullable) {
             block.get_by_position(result).column =
                     ColumnNullable::create(std::move(col_to), 
std::move(col_null_map_to));
         } else {
diff --git a/be/src/vec/functions/cast/cast_to_ip.h 
b/be/src/vec/functions/cast/cast_to_ip.h
index c953830b54d..ff2012772c9 100644
--- a/be/src/vec/functions/cast/cast_to_ip.h
+++ b/be/src/vec/functions/cast/cast_to_ip.h
@@ -59,27 +59,24 @@ public:
 
         auto to_type = block.get_by_position(result).type;
         auto serde = remove_nullable(to_type)->get_serde();
-        MutableColumnPtr column_to;
+
+        // by default framework, to_type is already unwrapped nullable
+        MutableColumnPtr column_to = to_type->create_column();
+        ColumnNullable::MutablePtr nullable_col_to = ColumnNullable::create(
+                std::move(column_to), ColumnUInt8::create(input_rows_count, 
0));
 
         if constexpr (Mode == CastModeType::NonStrictMode) {
-            auto to_nullable_type = make_nullable(to_type);
-            column_to = to_nullable_type->create_column();
-            auto& nullable_col_to = assert_cast<ColumnNullable&>(*column_to);
-            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
nullable_col_to, {}));
+            // may write nulls to nullable_col_to
+            RETURN_IF_ERROR(serde->from_string_batch(*col_from, 
*nullable_col_to, {}));
         } else if constexpr (Mode == CastModeType::StrictMode) {
-            if (to_type->is_nullable()) {
-                return Status::InternalError(
-                        "result type should be not nullable when casting 
string to ip in "
-                        "strict cast mode");
-            }
-            column_to = to_type->create_column();
-            RETURN_IF_ERROR(
-                    serde->from_string_strict_mode_batch(*col_from, 
*column_to, {}, null_map));
+            // WON'T write nulls to nullable_col_to, just raise errors. 
null_map is only used to skip invalid rows
+            RETURN_IF_ERROR(serde->from_string_strict_mode_batch(
+                    *col_from, nullable_col_to->get_nested_column(), {}, 
null_map));
         } else {
             return Status::InternalError("Unsupported cast mode");
         }
 
-        block.get_by_position(result).column = std::move(column_to);
+        block.get_by_position(result).column = std::move(nullable_col_to);
         return Status::OK();
     }
 };
diff --git a/be/src/vec/functions/cast/cast_to_jsonb.h 
b/be/src/vec/functions/cast/cast_to_jsonb.h
index 8a3e9ae0623..92e3d4954a9 100644
--- a/be/src/vec/functions/cast/cast_to_jsonb.h
+++ b/be/src/vec/functions/cast/cast_to_jsonb.h
@@ -17,6 +17,7 @@
 
 #include "cast_base.h"
 #include "runtime/jsonb_value.h"
+#include "runtime/primitive_type.h"
 #include "util/jsonb_utils.h"
 #include "util/jsonb_writer.h"
 #include "vec/common/assert_cast.h"
@@ -172,12 +173,13 @@ struct ParseJsonbFromString {
     static Status execute_non_strict(const ColumnString& col_from, size_t size,
                                      ColumnPtr& column_result) {
         auto col_to = ColumnString::create();
-        auto col_null = ColumnUInt8::create(size, 0);
+        auto col_null = ColumnBool::create(size, 0);
         auto& vec_null_map_to = col_null->get_data();
+
         for (size_t i = 0; i < size; ++i) {
             Status st = parse_json(col_from.get_data_at(i), *col_to);
             vec_null_map_to[i] = !st.ok();
-            if (!st.ok()) {
+            if (!st.ok()) [[unlikely]] {
                 col_to->insert_default();
             }
         }
@@ -185,6 +187,7 @@ struct ParseJsonbFromString {
         return Status::OK();
     }
 
+    // in both strict or non-strict mode, the return type is nullable column
     static Status execute_strict(const ColumnString& col_from, const 
NullMap::value_type* null_map,
                                  size_t size, ColumnPtr& column_result) {
         auto col_to = ColumnString::create();
@@ -195,7 +198,7 @@ struct ParseJsonbFromString {
             }
             RETURN_IF_ERROR(parse_json(col_from.get_data_at(i), *col_to));
         }
-        column_result = std::move(col_to);
+        column_result = ColumnNullable::create(std::move(col_to), 
ColumnBool::create(size, 0));
         return Status::OK();
     }
 
diff --git a/be/test/vec/function/cast/cast_to_integer.cpp 
b/be/test/vec/function/cast/cast_to_integer.cpp
index 1c1e96a6e4d..0bb88b2349e 100644
--- a/be/test/vec/function/cast/cast_to_integer.cpp
+++ b/be/test/vec/function/cast/cast_to_integer.cpp
@@ -1586,7 +1586,7 @@ struct FunctionCastToIntTest : public FunctionCastTest {
                     auto decimal_num = decimal_ctor(i, 0, FromScale);
                     data_set.push_back({{decimal_num}, Null()});
                     check_function_for_cast<DataTypeNumber<ToPT>, 
true>(input_types, data_set, -1,
-                                                                        -1, 
true, true);
+                                                                        -1, 
true);
                 }
             }
             return;
@@ -1628,7 +1628,7 @@ struct FunctionCastToIntTest : public FunctionCastTest {
                         data_set.push_back({{decimal_num}, Null()});
                     }
                     check_function_for_cast<DataTypeNumber<ToPT>, 
true>(input_types, data_set, -1,
-                                                                        -1, 
true, true);
+                                                                        -1, 
true);
                 }
             }
         }
@@ -2235,7 +2235,8 @@ TEST_F(FunctionCastToIntTest, test_from_decimal) {
 
     from_decimal_to_int_test_func<Decimal128V2, TYPE_LARGEINT>();
 }
-TEST_F(FunctionCastToIntTest, test_from_decimal_overflow) {
+TEST_F(FunctionCastToIntTest, DISABLE_test_from_decimal_overflow) {
+    GTEST_SKIP();
     from_decimal_to_int_overflow_test_func<Decimal32, TYPE_TINYINT>();
     from_decimal_to_int_overflow_test_func<Decimal64, TYPE_TINYINT>();
     from_decimal_to_int_overflow_test_func<Decimal128V3, TYPE_TINYINT>();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
index 69280d38321..818ae5f8cbf 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java
@@ -31,7 +31,6 @@ import org.apache.doris.nereids.types.LargeIntType;
 import org.apache.doris.nereids.types.SmallIntType;
 import org.apache.doris.nereids.types.TinyIntType;
 import org.apache.doris.nereids.types.coercion.DateLikeType;
-import org.apache.doris.qe.SessionVariable;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
@@ -79,18 +78,6 @@ public class Cast extends Expression implements 
UnaryExpression, Monotonic {
 
     @Override
     public boolean nullable() {
-        if (SessionVariable.enableStrictCast()) {
-            DataType childDataType = child().getDataType();
-            if (childDataType.isJsonType() && !targetType.isJsonType()) {
-                return true;
-            }
-            return child().nullable();
-        } else {
-            return unStrictCastNullable();
-        }
-    }
-
-    protected boolean unStrictCastNullable() {
         if (child().nullable()) {
             return true;
         }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java
index 98628b82139..4b058ade725 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Date.java
@@ -39,6 +39,7 @@ import java.util.List;
 public class Date extends ScalarFunction
         implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable, PropagateNullLiteral, Monotonic {
 
+    //TODO: eliminate this function for Date input
     public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.ret(DateV2Type.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
     );
diff --git 
a/regression-test/suites/function_p0/cast/test_cast_to_complex_types_strict.groovy
 
b/regression-test/suites/function_p0/cast/test_cast_to_complex_types_strict.groovy
index b93d7a587e2..8f4e4ed58e8 100644
--- 
a/regression-test/suites/function_p0/cast/test_cast_to_complex_types_strict.groovy
+++ 
b/regression-test/suites/function_p0/cast/test_cast_to_complex_types_strict.groovy
@@ -164,4 +164,10 @@ suite("test_cast_to_complex_types_strict") {
         CAST(ARRAY('123', '456') AS ARRAY<INT>) AS array_str_to_int,
         CAST(MAP('1', '2', '3','4') AS MAP<INT, INT>) AS map_str_to_int;
     """
+
+    sql "set enable_strict_cast = true;"
+    test {
+        sql "select cast('[99.12.31 23.59.59+05:30]' as array<date>);"
+        exception "INVALID_ARGUMENT"
+    }
 }
diff --git a/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy 
b/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
index 8c0cbd5cdff..ac3b255cdfd 100644
--- a/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
+++ b/regression-test/suites/prepared_stmt_p0/prepared_stmt.groovy
@@ -26,7 +26,6 @@ suite("test_prepared_stmt", "nonConcurrent") {
     """
     sql """ ADMIN SET FRONTEND CONFIG ("prepared_stmt_start_id" = "-1"); """
 
-    def tableName = "tbl_prepared_stmt"
     def user = context.config.jdbcUser
     def password = context.config.jdbcPassword
     // def url = context.config.jdbcUrl + 
"&useServerPrepStmts=true&useCursorFetch=true"
@@ -34,9 +33,9 @@ suite("test_prepared_stmt", "nonConcurrent") {
     logger.info("jdbc prepare statement url: ${url}")
     def result1 = connect(user, password, url) {
 
-        sql """DROP TABLE IF EXISTS ${tableName} """
+        sql """DROP TABLE IF EXISTS tbl_prepared_stmt """
         sql """
-             CREATE TABLE IF NOT EXISTS ${tableName} (
+             CREATE TABLE IF NOT EXISTS tbl_prepared_stmt (
                      `k1` int(11) NULL COMMENT "",
                      `k2` decimalv3(27, 9) NULL COMMENT "",
                      `k3` varchar(30) NULL COMMENT "",
@@ -56,17 +55,17 @@ suite("test_prepared_stmt", "nonConcurrent") {
                    )
                """
 
-        sql """ INSERT INTO ${tableName} VALUES(1231, 119291.11, "ddd", 
"laooq", null, "2020-01-01 12:36:38", null, "1022-01-01 11:30:38", "[2022-01-01 
11:30:38, 2022-01-01 11:30:38, 2022-01-01 11:30:38]") """
-        sql """ INSERT INTO ${tableName} VALUES(1232, 12222.99121135, "xxx", 
"laooq", "2023-01-02", "2020-01-01 12:36:38", 522.762, "2022-01-01 11:30:38", 
"[2023-01-01 11:30:38, 2023-01-01 11:30:38]") """
-        sql """ INSERT INTO ${tableName} VALUES(1233, 1.392932911136, "yyy", 
"laooq", "2024-01-02", "2020-01-01 12:36:38", 52.862, "3022-01-01 11:30:38", 
"[2024-01-01 11:30:38, 2024-01-01 11:30:38, 2024-01-01 11:30:38]") """
-        sql """ INSERT INTO ${tableName} VALUES(1234, 12919291.129191137, 
"xxddd", "laooq", "2025-01-02", "2020-01-01 12:36:38", 552.872, "4022-01-01 
11:30:38", "[2025-01-01 11:30:38, 2025-01-01 11:30:38, 2025-01-01 11:30:38]") 
"""
-        sql """ INSERT INTO ${tableName} VALUES(1235, 991129292901.11138, 
"dd", null, "2120-01-02", "2020-01-01 12:36:38", 652.692, "5022-01-01 
11:30:38", "[]") """
-        sql """ INSERT INTO ${tableName} VALUES(1236, 100320.11139, "laa    
ddd", "laooq", "2220-01-02", "2020-01-01 12:36:38", 2.7692, "6022-01-01 
11:30:38", "[null]") """
-        sql """ INSERT INTO ${tableName} VALUES(1237, 120939.11130, "a    
ddd", "laooq", "2030-01-02", "2020-01-01 12:36:38", 22.822, "7022-01-01 
11:30:38", "[2025-01-01 11:30:38]") """
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1231, 119291.11, "ddd", 
"laooq", null, "2020-01-01 12:36:38", null, "1022-01-01 11:30:38", "[2022-01-01 
11:30:38, 2022-01-01 11:30:38, 2022-01-01 11:30:38]") """
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1232, 12222.99121135, 
"xxx", "laooq", "2023-01-02", "2020-01-01 12:36:38", 522.762, "2022-01-01 
11:30:38", "[2023-01-01 11:30:38, 2023-01-01 11:30:38]") """
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1233, 1.392932911136, 
"yyy", "laooq", "2024-01-02", "2020-01-01 12:36:38", 52.862, "3022-01-01 
11:30:38", "[2024-01-01 11:30:38, 2024-01-01 11:30:38, 2024-01-01 11:30:38]") 
"""
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1234, 12919291.129191137, 
"xxddd", "laooq", "2025-01-02", "2020-01-01 12:36:38", 552.872, "4022-01-01 
11:30:38", "[2025-01-01 11:30:38, 2025-01-01 11:30:38, 2025-01-01 11:30:38]") 
"""
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1235, 991129292901.11138, 
"dd", null, "2120-01-02", "2020-01-01 12:36:38", 652.692, "5022-01-01 
11:30:38", "[]") """
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1236, 100320.11139, "laa  
  ddd", "laooq", "2220-01-02", "2020-01-01 12:36:38", 2.7692, "6022-01-01 
11:30:38", "[null]") """
+        sql """ INSERT INTO tbl_prepared_stmt VALUES(1237, 120939.11130, "a    
ddd", "laooq", "2030-01-02", "2020-01-01 12:36:38", 22.822, "7022-01-01 
11:30:38", "[2025-01-01 11:30:38]") """
         sql """sync"""
 
-        qt_sql """select * from  ${tableName} order by 1, 2, 3"""
-        qt_sql """select * from  ${tableName} order by 1, 2, 3"""
+        qt_sql """select * from  tbl_prepared_stmt order by 1, 2, 3"""
+        qt_sql """select * from  tbl_prepared_stmt order by 1, 2, 3"""
         sql "set global max_prepared_stmt_count = 10000"
         sql "set enable_fallback_to_original_planner = false"
         sql """set global enable_server_side_prepared_statement = true"""
@@ -78,17 +77,17 @@ suite("test_prepared_stmt", "nonConcurrent") {
             sb.append(", ?");
         }
         String sqlWithTooManyPlaceholder = sb.toString();
-        def stmt_read = prepareStatement "select * from ${tableName} where k1 
in (${sqlWithTooManyPlaceholder})"
+        def stmt_read = prepareStatement "select * from tbl_prepared_stmt 
where k1 in (${sqlWithTooManyPlaceholder})"
         assertEquals(com.mysql.cj.jdbc.ClientPreparedStatement, 
stmt_read.class)
 
-        stmt_read = prepareStatement "select * from ${tableName} where k1 = ? 
order by k1"
+        stmt_read = prepareStatement "select * from tbl_prepared_stmt where k1 
= ? order by k1"
         assertEquals(com.mysql.cj.jdbc.ServerPreparedStatement, 
stmt_read.class)
         stmt_read.setInt(1, 1231)
         qe_select0 stmt_read
         stmt_read.setInt(1, 1232)
         qe_select0 stmt_read
         qe_select0 stmt_read
-        def stmt_read1 = prepareStatement "select hex(k3), ? \n from 
${tableName} where k1 = ? order by 1"
+        def stmt_read1 = prepareStatement "select hex(k3), ? \n from 
tbl_prepared_stmt where k1 = ? order by 1"
         assertEquals(com.mysql.cj.jdbc.ServerPreparedStatement, 
stmt_read.class)
         stmt_read1.setString(1, "xxxx---")
         stmt_read1.setInt(2, 1231)
@@ -98,7 +97,7 @@ suite("test_prepared_stmt", "nonConcurrent") {
         qe_select1 stmt_read1
         qe_select1 stmt_read1
         stmt_read1.close()
-        def stmt_read2 = prepareStatement "select * from ${tableName} as t1 
join ${tableName} as t2 on t1.`k1` = t2.`k1` where t1.`k1` >= ? and t1.`k2` >= 
? and size(t1.`k9`) > ? order by 1, 2, 3"
+        def stmt_read2 = prepareStatement "select * from tbl_prepared_stmt as 
t1 join tbl_prepared_stmt as t2 on t1.`k1` = t2.`k1` where t1.`k1` >= ? and 
t1.`k2` >= ? and size(t1.`k9`) > ? order by 1, 2, 3"
         assertEquals(com.mysql.cj.jdbc.ServerPreparedStatement, 
stmt_read.class)
         stmt_read2.setInt(1, 1237)
         stmt_read2.setBigDecimal(2, new BigDecimal("120939.11130"))


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

Reply via email to