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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 2b427c316a2 [feature](functions) impl scalar functions 
normal_cdf,to_iso8601,from_iso8601_date (#40695) (#41049)
2b427c316a2 is described below

commit 2b427c316a230e5d89d2634eec757b6d35ecce6e
Author: daidai <2017501...@qq.com>
AuthorDate: Tue Sep 24 09:52:39 2024 +0800

    [feature](functions) impl scalar functions 
normal_cdf,to_iso8601,from_iso8601_date (#40695) (#41049)
    
    bp #40695
---
 be/src/vec/functions/date_time_transforms.h        |  23 ++
 .../function_date_or_datetime_to_string.cpp        |   5 +
 be/src/vec/functions/function_timestamp.cpp        | 253 ++++++++++++++++++++-
 be/src/vec/functions/math.cpp                      |  74 ++++++
 .../doris/catalog/BuiltinScalarFunctions.java      |   6 +
 .../functions/scalar/FromIso8601Date.java          |  72 ++++++
 .../expressions/functions/scalar/NormalCdf.java    |  69 ++++++
 .../expressions/functions/scalar/ToIso8601.java    |  76 +++++++
 .../expressions/visitor/ScalarFunctionVisitor.java |  15 ++
 .../datetime_functions/test_from_iso8601_date.out  | 244 ++++++++++++++++++++
 .../datetime_functions/test_to_iso8601.out         | 194 ++++++++++++++++
 .../math_functions/test_normal_cdf.out             | 201 ++++++++++++++++
 .../test_from_iso8601_date.groovy                  | 149 ++++++++++++
 .../datetime_functions/test_to_iso8601.groovy      | 150 ++++++++++++
 .../math_functions/test_normal_cdf.groovy          |  93 ++++++++
 15 files changed, 1623 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/functions/date_time_transforms.h 
b/be/src/vec/functions/date_time_transforms.h
index 266c9b5d272..eb1791e9177 100644
--- a/be/src/vec/functions/date_time_transforms.h
+++ b/be/src/vec/functions/date_time_transforms.h
@@ -156,6 +156,29 @@ struct DayNameImpl {
     }
 };
 
+template <typename ArgType>
+struct ToIso8601Impl {
+    using OpArgType = ArgType;
+    static constexpr auto name = "to_iso8601";
+    static constexpr auto max_size = std::is_same_v<ArgType, UInt32> ? 10 : 26;
+
+    static inline auto execute(const typename DateTraits<ArgType>::T& dt,
+                               ColumnString::Chars& res_data, size_t& offset) {
+        auto length = dt.to_buffer((char*)res_data.data() + offset,
+                                   std::is_same_v<ArgType, UInt32> ? -1 : 6);
+        if (std::is_same_v<ArgType, UInt64>) {
+            res_data[offset + 10] = 'T';
+        }
+
+        offset += length;
+        return offset;
+    }
+
+    static DataTypes get_variadic_argument_types() {
+        return {std::make_shared<typename DateTraits<ArgType>::DateType>()};
+    }
+};
+
 template <typename ArgType>
 struct MonthNameImpl {
     using OpArgType = ArgType;
diff --git a/be/src/vec/functions/function_date_or_datetime_to_string.cpp 
b/be/src/vec/functions/function_date_or_datetime_to_string.cpp
index b8f1c320663..8c3fd755a0f 100644
--- a/be/src/vec/functions/function_date_or_datetime_to_string.cpp
+++ b/be/src/vec/functions/function_date_or_datetime_to_string.cpp
@@ -33,6 +33,9 @@ using FunctionMonthNameV2 = 
FunctionDateOrDateTimeToString<MonthNameImpl<UInt32>
 using FunctionDateTimeV2DayName = 
FunctionDateOrDateTimeToString<DayNameImpl<UInt64>>;
 using FunctionDateTimeV2MonthName = 
FunctionDateOrDateTimeToString<MonthNameImpl<UInt64>>;
 
+using FunctionDateIso8601 = 
FunctionDateOrDateTimeToString<ToIso8601Impl<UInt32>>;
+using FunctionDateTimeIso8601 = 
FunctionDateOrDateTimeToString<ToIso8601Impl<UInt64>>;
+
 void register_function_date_time_to_string(SimpleFunctionFactory& factory) {
     factory.register_function<FunctionDayName>();
     factory.register_function<FunctionMonthName>();
@@ -40,6 +43,8 @@ void 
register_function_date_time_to_string(SimpleFunctionFactory& factory) {
     factory.register_function<FunctionMonthNameV2>();
     factory.register_function<FunctionDateTimeV2DayName>();
     factory.register_function<FunctionDateTimeV2MonthName>();
+    factory.register_function<FunctionDateIso8601>();
+    factory.register_function<FunctionDateTimeIso8601>();
 }
 
 } // namespace doris::vectorized
diff --git a/be/src/vec/functions/function_timestamp.cpp 
b/be/src/vec/functions/function_timestamp.cpp
index 483f8cf9928..7bc16f36b96 100644
--- a/be/src/vec/functions/function_timestamp.cpp
+++ b/be/src/vec/functions/function_timestamp.cpp
@@ -77,6 +77,8 @@ struct StrToDate {
 
     static bool is_variadic() { return false; }
 
+    static size_t get_number_of_arguments() { return 2; }
+
     static DataTypes get_variadic_argument_types() {
         return {std::make_shared<DataTypeString>(), 
std::make_shared<DataTypeString>()};
     }
@@ -245,6 +247,8 @@ struct MakeDateImpl {
 
     static bool is_variadic() { return false; }
 
+    static size_t get_number_of_arguments() { return 2; }
+
     static DataTypes get_variadic_argument_types() { return {}; }
 
     static DataTypePtr get_return_type_impl(const DataTypes& arguments) {
@@ -408,6 +412,8 @@ struct DateTrunc {
 
     static bool is_variadic() { return true; }
 
+    static size_t get_number_of_arguments() { return 2; }
+
     static DataTypes get_variadic_argument_types() {
         return {std::make_shared<DateType>(), 
std::make_shared<DataTypeString>()};
     }
@@ -1332,7 +1338,7 @@ public:
 
     String get_name() const override { return name; }
 
-    size_t get_number_of_arguments() const override { return 2; }
+    size_t get_number_of_arguments() const override { return 
Impl::get_number_of_arguments(); }
 
     bool is_variadic() const override { return Impl::is_variadic(); }
 
@@ -1364,6 +1370,249 @@ public:
     }
 };
 
+struct FromIso8601DateV2 {
+    static constexpr auto name = "from_iso8601_date";
+
+    static size_t get_number_of_arguments() { return 1; }
+
+    static bool is_variadic() { return false; }
+
+    static DataTypes get_variadic_argument_types() { return 
{std::make_shared<DataTypeString>()}; }
+
+    static DataTypePtr get_return_type_impl(const DataTypes& arguments) {
+        return make_nullable(std::make_shared<DataTypeDateV2>());
+    }
+
+    static Status execute(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                          size_t result, size_t input_rows_count) {
+        const auto* src_column_ptr = 
block.get_by_position(arguments[0]).column.get();
+
+        auto null_map = ColumnUInt8::create(input_rows_count, 0);
+
+        ColumnDateV2::MutablePtr res = ColumnDateV2::create(input_rows_count);
+        auto& result_data = res->get_data();
+
+        static const std::tuple<std::vector<int>, int, std::string> 
ISO_STRING_FORMAT[] = {
+                {{
+                         8,
+                 },
+                 1,
+                 "%04d%02d%02d"},                         //YYYYMMDD
+                {{4, -1, 2, -1, 2}, 1, "%04d-%02d-%02d"}, //YYYY-MM-DD
+                {{4, -1, 2}, 2, "%04d-%02d"},             //YYYY-MM
+                {
+                        {
+                                4,
+                        },
+                        3,
+                        "%04d",
+                }, //YYYY
+                {
+                        {4, -1, 3},
+                        4,
+                        "%04d-%03d",
+                }, //YYYY-DDD
+                {
+                        {
+                                7,
+                        },
+                        4,
+                        "%04d%03d",
+                }, //YYYYDDD
+                {
+                        {4, -1, -2, 2},
+                        5,
+                        "%04d-W%02d",
+                }, //YYYY-Www
+                {
+                        {4, -2, 2},
+                        5,
+                        "%04dW%02d",
+                }, //YYYYWww
+                {
+                        {4, -1, -2, 2, -1, 1},
+                        6,
+                        "%04d-W%02d-%1d",
+                }, //YYYY-Www-D
+                {
+                        {4, -2, 3},
+                        6,
+                        "%04dW%02d%1d",
+                }, //YYYYWwwD
+        };
+
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            int year, month, day, week, day_of_year;
+            int weekday = 1; // YYYYWww  YYYY-Www  default D = 1
+            auto src_string = src_column_ptr->get_data_at(i).to_string_view();
+
+            int iso_string_format_value = 0;
+
+            vector<int> src_string_values;
+            src_string_values.reserve(10);
+
+            //The maximum length of the current iso8601 format is 10.
+            if (src_string.size() <= 10) {
+                // The calculation string corresponds to the iso8601 format.
+                // The integer represents the number of consecutive numbers.
+                // -1 represent char '-'.
+                // -2 represent char 'W'.
+                //  The calculated vector `src_string_values`  will be 
compared with `ISO_STRING_FORMAT[]` later.
+                for (int idx = 0; idx < src_string.size();) {
+                    char current = src_string[idx];
+                    if (current == '-') {
+                        src_string_values.emplace_back(-1);
+                        idx++;
+                        continue;
+                    } else if (current == 'W') {
+                        src_string_values.emplace_back(-2);
+                        idx++;
+                        continue;
+                    } else if (!isdigit(current)) {
+                        iso_string_format_value = -1;
+                        break;
+                    }
+                    int currLen = 0;
+                    for (; idx < src_string.size() && 
isdigit(src_string[idx]); ++idx) {
+                        ++currLen;
+                    }
+                    src_string_values.emplace_back(currLen);
+                }
+            } else {
+                iso_string_format_value = -1;
+            }
+
+            std::string_view iso_format_string;
+            if (iso_string_format_value != -1) {
+                for (const auto& j : ISO_STRING_FORMAT) {
+                    const auto& v = std::get<0>(j);
+                    if (v == src_string_values) {
+                        iso_string_format_value = std::get<1>(j);
+                        iso_format_string = std::get<2>(j);
+                        break;
+                    }
+                }
+            }
+
+            auto& ts_value = 
*reinterpret_cast<DateV2Value<DateV2ValueType>*>(&result_data[i]);
+            if (iso_string_format_value == 1) {
+                if (sscanf(src_string.data(), iso_format_string.data(), &year, 
&month, &day) != 3)
+                        [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                if (!(ts_value.template set_time_unit<YEAR>(year) &&
+                      ts_value.template set_time_unit<MONTH>(month) &&
+                      ts_value.template set_time_unit<DAY>(day))) [[unlikely]] 
{
+                    null_map->get_data().data()[i] = true;
+                }
+            } else if (iso_string_format_value == 2) {
+                if (sscanf(src_string.data(), iso_format_string.data(), &year, 
&month) != 2)
+                        [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                if (!(ts_value.template set_time_unit<YEAR>(year) &&
+                      ts_value.template set_time_unit<MONTH>(month) &&
+                      ts_value.template set_time_unit<DAY>(1))) [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                }
+
+            } else if (iso_string_format_value == 3) {
+                if (sscanf(src_string.data(), iso_format_string.data(), &year) 
!= 1) [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                if (!(ts_value.template set_time_unit<YEAR>(year) &&
+                      ts_value.template set_time_unit<MONTH>(1) &&
+                      ts_value.template set_time_unit<DAY>(1))) [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                }
+
+            } else if (iso_string_format_value == 5 || iso_string_format_value 
== 6) {
+                if (iso_string_format_value == 5) {
+                    if (sscanf(src_string.data(), iso_format_string.data(), 
&year, &week) != 2)
+                            [[unlikely]] {
+                        null_map->get_data().data()[i] = true;
+                        continue;
+                    }
+                } else {
+                    if (sscanf(src_string.data(), iso_format_string.data(), 
&year, &week,
+                               &weekday) != 3) [[unlikely]] {
+                        null_map->get_data().data()[i] = true;
+                        continue;
+                    }
+                }
+                // weekday [1,7]    week [1,53]
+                if (weekday < 1 || weekday > 7 || week < 1 || week > 53) 
[[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                auto first_day_of_week = getFirstDayOfISOWeek(year);
+                if (!(ts_value.template set_time_unit<YEAR>(
+                              first_day_of_week.year().operator int()) &&
+                      ts_value.template set_time_unit<MONTH>(
+                              first_day_of_week.month().operator unsigned 
int()) &&
+                      ts_value.template set_time_unit<DAY>(
+                              first_day_of_week.day().operator unsigned 
int()))) [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                auto day_diff = (week - 1) * 7 + weekday - 1;
+                TimeInterval interval(DAY, day_diff, false);
+
+                ts_value.date_add_interval<DAY>(interval);
+            } else if (iso_string_format_value == 4) {
+                if (sscanf(src_string.data(), iso_format_string.data(), &year, 
&day_of_year) != 2)
+                        [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                if (is_leap(year)) {
+                    if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
+                        null_map->get_data().data()[i] = true;
+                    }
+                } else {
+                    if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
+                        null_map->get_data().data()[i] = true;
+                    }
+                }
+                if (!(ts_value.template set_time_unit<YEAR>(year) &&
+                      ts_value.template set_time_unit<MONTH>(1) &&
+                      ts_value.template set_time_unit<DAY>(1))) [[unlikely]] {
+                    null_map->get_data().data()[i] = true;
+                    continue;
+                }
+
+                TimeInterval interval(DAY, day_of_year - 1, false);
+                ts_value.template date_add_interval<DAY>(interval);
+            } else {
+                null_map->get_data().data()[i] = true;
+            }
+        }
+        block.get_by_position(result).column =
+                ColumnNullable::create(std::move(res), std::move(null_map));
+        return Status::OK();
+    }
+
+private:
+    //Get the date corresponding to Monday of the first week of the year 
according to the ISO8601 standard.
+    static std::chrono::year_month_day getFirstDayOfISOWeek(int year) {
+        using namespace std::chrono;
+        auto jan4 = year_month_day {std::chrono::year(year) / January / 4};
+        auto jan4_sys_days = sys_days {jan4};
+        auto weekday_of_jan4 = weekday {jan4_sys_days};
+        auto first_day_of_week = jan4_sys_days - days 
{(weekday_of_jan4.iso_encoding() - 1)};
+        return year_month_day {floor<days>(first_day_of_week)};
+    }
+};
+
 using FunctionStrToDate = 
FunctionOtherTypesToDateType<StrToDate<DataTypeDate>>;
 using FunctionStrToDatetime = 
FunctionOtherTypesToDateType<StrToDate<DataTypeDateTime>>;
 using FunctionStrToDateV2 = 
FunctionOtherTypesToDateType<StrToDate<DataTypeDateV2>>;
@@ -1373,6 +1622,7 @@ using FunctionDateTruncDate = 
FunctionOtherTypesToDateType<DateTrunc<DataTypeDat
 using FunctionDateTruncDateV2 = 
FunctionOtherTypesToDateType<DateTrunc<DataTypeDateV2>>;
 using FunctionDateTruncDatetime = 
FunctionOtherTypesToDateType<DateTrunc<DataTypeDateTime>>;
 using FunctionDateTruncDatetimeV2 = 
FunctionOtherTypesToDateType<DateTrunc<DataTypeDateTimeV2>>;
+using FunctionFromIso8601DateV2 = 
FunctionOtherTypesToDateType<FromIso8601DateV2>;
 
 void register_function_timestamp(SimpleFunctionFactory& factory) {
     factory.register_function<FunctionStrToDate>();
@@ -1385,6 +1635,7 @@ void register_function_timestamp(SimpleFunctionFactory& 
factory) {
     factory.register_function<FunctionDateTruncDateV2>();
     factory.register_function<FunctionDateTruncDatetime>();
     factory.register_function<FunctionDateTruncDatetimeV2>();
+    factory.register_function<FunctionFromIso8601DateV2>();
 
     factory.register_function<FunctionUnixTimestamp<UnixTimeStampImpl>>();
     
factory.register_function<FunctionUnixTimestamp<UnixTimeStampDateImpl<DataTypeDate>>>();
diff --git a/be/src/vec/functions/math.cpp b/be/src/vec/functions/math.cpp
index 7c55866e2c4..ff864cdcb07 100644
--- a/be/src/vec/functions/math.cpp
+++ b/be/src/vec/functions/math.cpp
@@ -329,6 +329,79 @@ struct PowName {
 };
 using FunctionPow = FunctionBinaryArithmetic<PowImpl, PowName, false>;
 
+class FunctionNormalCdf : public IFunction {
+public:
+    static constexpr auto name = "normal_cdf";
+
+    String get_name() const override { return name; }
+
+    static FunctionPtr create() { return 
std::make_shared<FunctionNormalCdf>(); }
+
+    DataTypePtr get_return_type_impl(const DataTypes& arguments) const 
override {
+        return make_nullable(std::make_shared<DataTypeFloat64>());
+    }
+
+    DataTypes get_variadic_argument_types_impl() const override {
+        return {std::make_shared<DataTypeFloat64>(), 
std::make_shared<DataTypeFloat64>(),
+                std::make_shared<DataTypeFloat64>()};
+    }
+    size_t get_number_of_arguments() const override { return 3; }
+
+    Status execute_impl(FunctionContext* context, Block& block, const 
ColumnNumbers& arguments,
+                        size_t result, size_t input_rows_count) const override 
{
+        auto result_column = ColumnFloat64::create(input_rows_count);
+        auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
+
+        auto& result_data = result_column->get_data();
+        NullMap& result_null_map =
+                
assert_cast<ColumnUInt8*>(result_null_map_column.get())->get_data();
+
+        ColumnPtr argument_columns[3];
+        bool col_const[3];
+        size_t argument_size = arguments.size();
+        for (int i = 0; i < argument_size; ++i) {
+            argument_columns[i] = block.get_by_position(arguments[i]).column;
+            col_const[i] = is_column_const(*argument_columns[i]);
+            if (col_const[i]) {
+                argument_columns[i] =
+                        static_cast<const 
ColumnConst&>(*argument_columns[i]).get_data_column_ptr();
+            }
+        }
+
+        auto* mean_col = assert_cast<const 
ColumnFloat64*>(argument_columns[0].get());
+        auto* sd_col = assert_cast<const 
ColumnFloat64*>(argument_columns[1].get());
+        auto* value_col = assert_cast<const 
ColumnFloat64*>(argument_columns[2].get());
+
+        result_column->reserve(input_rows_count);
+        for (size_t i = 0; i < input_rows_count; ++i) {
+            double mean = mean_col->get_element(index_check_const(i, 
col_const[0]));
+            double sd = sd_col->get_element(index_check_const(i, 
col_const[1]));
+            double v = value_col->get_element(index_check_const(i, 
col_const[2]));
+
+            if (!check_argument(sd)) [[unlikely]] {
+                result_null_map[i] = true;
+                continue;
+            }
+            result_data[i] = calculate_cell(mean, sd, v);
+        }
+
+        block.get_by_position(result).column =
+                ColumnNullable::create(std::move(result_column), 
std::move(result_null_map_column));
+        return Status::OK();
+    }
+
+    static bool check_argument(double sd) { return sd > 0; }
+    static double calculate_cell(double mean, double sd, double v) {
+#ifdef __APPLE__
+        const double sqrt2 = std::sqrt(2);
+#else
+        constexpr double sqrt2 = std::numbers::sqrt2;
+#endif
+
+        return 0.5 * (std::erf((v - mean) / (sd * sqrt2)) + 1);
+    }
+};
+
 // TODO: Now math may cause one thread compile time too long, because the 
function in math
 // so mush. Split it to speed up compile time in the future
 void register_function_math(SimpleFunctionFactory& factory) {
@@ -365,5 +438,6 @@ void register_function_math(SimpleFunctionFactory& factory) 
{
     factory.register_function<FunctionRadians>();
     factory.register_function<FunctionDegrees>();
     factory.register_function<FunctionBin>();
+    factory.register_function<FunctionNormalCdf>();
 }
 } // namespace doris::vectorized
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
index 4210a645784..aec39e9df20 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java
@@ -171,6 +171,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.Fmod;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Fpow;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.FromBase64;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.FromDays;
+import 
org.apache.doris.nereids.trees.expressions.functions.scalar.FromIso8601Date;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.FromMicrosecond;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.FromMillisecond;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.FromSecond;
@@ -307,6 +308,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash364
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Negative;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.NgramSearch;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.NonNullable;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.NormalCdf;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.NotNullOrEmpty;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Now;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.NullIf;
@@ -414,6 +416,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv4OrNull;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6OrDefault;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6OrNull;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.ToIso8601;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ToMonday;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToQuantileState;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Tokenize;
@@ -614,6 +617,7 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(Fpow.class, "fpow"),
             scalar(FromBase64.class, "from_base64"),
             scalar(FromDays.class, "from_days"),
+            scalar(FromIso8601Date.class, "from_iso8601_date"),
             scalar(FromUnixtime.class, "from_unixtime"),
             scalar(G.class, "g"),
             scalar(GetJsonBigInt.class, "get_json_bigint"),
@@ -764,6 +768,7 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(MurmurHash364.class, "murmur_hash3_64"),
             scalar(Negative.class, "negative"),
             scalar(NonNullable.class, "non_nullable"),
+            scalar(NormalCdf.class, "normal_cdf"),
             scalar(NotNullOrEmpty.class, "not_null_or_empty"),
             scalar(NgramSearch.class, "ngram_search"),
             scalar(Now.class, "now", "current_timestamp", "localtime", 
"localtimestamp"),
@@ -877,6 +882,7 @@ public class BuiltinScalarFunctions implements 
FunctionHelper {
             scalar(ToIpv6.class, "to_ipv6"),
             scalar(ToIpv6OrDefault.class, "to_ipv6_or_default"),
             scalar(ToIpv6OrNull.class, "to_ipv6_or_null"),
+            scalar(ToIso8601.class, "to_iso8601"),
             scalar(Tokenize.class, "tokenize"),
             scalar(ToMonday.class, "to_monday"),
             scalar(ToQuantileState.class, "to_quantile_state"),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromIso8601Date.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromIso8601Date.java
new file mode 100644
index 00000000000..e0e3e41548a
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/FromIso8601Date.java
@@ -0,0 +1,72 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
+import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DateV2Type;
+import org.apache.doris.nereids.types.StringType;
+import org.apache.doris.nereids.types.VarcharType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * ScalarFunction 'from_iso8601_date'. This class is generated by 
GenerateFunction.
+ */
+public class FromIso8601Date extends ScalarFunction
+        implements UnaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(DateV2Type.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
+            
FunctionSignature.ret(DateV2Type.INSTANCE).args(StringType.INSTANCE)
+    );
+
+    /**
+     * constructor with 1 argument.
+     */
+    public FromIso8601Date(Expression arg0) {
+        super("from_iso8601_date", arg0);
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public FromIso8601Date withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 1);
+        return new FromIso8601Date(children.get(0));
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitFromIso8601Date(this, context);
+    }
+
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NormalCdf.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NormalCdf.java
new file mode 100644
index 00000000000..c68e610679c
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/NormalCdf.java
@@ -0,0 +1,69 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
+import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.shape.TernaryExpression;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DoubleType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * ScalarFunction 'normal_cdf'. This class is generated by GenerateFunction.
+ */
+public class NormalCdf extends ScalarFunction
+        implements TernaryExpression, ExplicitlyCastableSignature, 
AlwaysNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            FunctionSignature.ret(DoubleType.INSTANCE)
+                    .args(DoubleType.INSTANCE, DoubleType.INSTANCE, 
DoubleType.INSTANCE)
+    );
+
+    /**
+     * constructor with 3 arguments.
+     */
+    public NormalCdf(Expression arg0, Expression arg1, Expression arg2) {
+        super("normal_cdf", arg0, arg1, arg2);
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public NormalCdf withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 3);
+        return new NormalCdf(children.get(0), children.get(1), 
children.get(2));
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitNormalCdf(this, context);
+    }
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToIso8601.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToIso8601.java
new file mode 100644
index 00000000000..d676157977d
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/ToIso8601.java
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.expressions.functions.scalar;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
+import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
+import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
+import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
+import org.apache.doris.nereids.types.DateTimeType;
+import org.apache.doris.nereids.types.DateTimeV2Type;
+import org.apache.doris.nereids.types.DateType;
+import org.apache.doris.nereids.types.DateV2Type;
+import org.apache.doris.nereids.types.StringType;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * ScalarFunction 'to_iso8601'. This class is generated by GenerateFunction.
+ */
+public class ToIso8601 extends ScalarFunction
+        implements UnaryExpression, ExplicitlyCastableSignature, 
PropagateNullable {
+
+    public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
+            
FunctionSignature.ret(StringType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
+            
FunctionSignature.ret(StringType.INSTANCE).args(DateV2Type.INSTANCE),
+            
FunctionSignature.ret(StringType.INSTANCE).args(DateTimeType.INSTANCE),
+            FunctionSignature.ret(StringType.INSTANCE).args(DateType.INSTANCE)
+            );
+
+    /**
+     * constructor with 1 argument.
+     */
+    public ToIso8601(Expression arg0) {
+        super("to_iso8601", arg0);
+    }
+
+    @Override
+    public List<FunctionSignature> getSignatures() {
+        return SIGNATURES;
+    }
+
+    /**
+     * withChildren.
+     */
+    @Override
+    public ToIso8601 withChildren(List<Expression> children) {
+        Preconditions.checkArgument(children.size() == 1);
+        return new ToIso8601(children.get(0));
+    }
+
+    @Override
+    public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
+        return visitor.visitToIso8601(this, context);
+    }
+
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
index 38aad42d3c5..0641a76ac21 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java
@@ -179,6 +179,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.Fmod;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Fpow;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.FromBase64;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.FromDays;
+import 
org.apache.doris.nereids.trees.expressions.functions.scalar.FromIso8601Date;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.FromUnixtime;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.G;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.GetJsonBigInt;
@@ -307,6 +308,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash332
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.MurmurHash364;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Negative;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.NgramSearch;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.NormalCdf;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.NotNullOrEmpty;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Now;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.NullIf;
@@ -411,6 +413,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv4OrNull;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6OrDefault;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToIpv6OrNull;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.ToIso8601;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.ToMonday;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.ToQuantileState;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Tokenize;
@@ -1130,6 +1133,10 @@ public interface ScalarFunctionVisitor<R, C> {
         return visitScalarFunction(fromDays, context);
     }
 
+    default R visitFromIso8601Date(FromIso8601Date fromIso8601Date, C context) 
{
+        return visitScalarFunction(fromIso8601Date, context);
+    }
+
     default R visitFromUnixtime(FromUnixtime fromUnixtime, C context) {
         return visitScalarFunction(fromUnixtime, context);
     }
@@ -1574,6 +1581,10 @@ public interface ScalarFunctionVisitor<R, C> {
         return visitScalarFunction(ngramSearch, context);
     }
 
+    default R visitNormalCdf(NormalCdf normalCdf, C context) {
+        return visitScalarFunction(normalCdf, context);
+    }
+
     default R visitNotNullOrEmpty(NotNullOrEmpty notNullOrEmpty, C context) {
         return visitScalarFunction(notNullOrEmpty, context);
     }
@@ -1990,6 +2001,10 @@ public interface ScalarFunctionVisitor<R, C> {
         return visitScalarFunction(toIpv6OrNull, context);
     }
 
+    default R visitToIso8601(ToIso8601 toIso8601, C context) {
+        return visitScalarFunction(toIso8601, context);
+    }
+
     default R visitToMonday(ToMonday toMonday, C context) {
         return visitScalarFunction(toMonday, context);
     }
diff --git 
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.out
 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.out
new file mode 100644
index 00000000000..43a4f0bd496
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.out
@@ -0,0 +1,244 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_31 --
+0000-01-01
+
+-- !test_32 --
+0001-01-01
+
+-- !test_33 --
+1900-01-01
+
+-- !test_34 --
+1970-01-01
+
+-- !test_35 --
+9999-01-01
+
+-- !test_36 --
+0000-01-01
+
+-- !test_37 --
+0000-02-28
+
+-- !test_38 --
+0001-02-28
+
+-- !test_39 --
+1900-02-28
+
+-- !test_40 --
+1970-01-01
+
+-- !test_41 --
+9999-12-31
+
+-- !test_42 --
+0000-02-28
+
+-- !test_43 --
+0001-02-28
+
+-- !test_44 --
+1900-02-28
+
+-- !test_45 --
+1970-01-01
+
+-- !test_46 --
+9999-12-31
+
+-- !test_47 --
+0000-01-01
+
+-- !test_48 --
+0000-02-01
+
+-- !test_49 --
+0001-03-01
+
+-- !test_50 --
+1900-03-01
+
+-- !test_51 --
+1970-01-01
+
+-- !test_52 --
+9999-12-01
+
+-- !test_53 --
+0000-01-03
+
+-- !test_54 --
+0000-02-28
+
+-- !test_55 --
+0001-02-26
+
+-- !test_56 --
+1900-02-19
+
+-- !test_57 --
+1969-12-29
+
+-- !test_58 --
+9999-12-27
+
+-- !test_59 --
+0000-01-03
+
+-- !test_60 --
+0000-03-05
+
+-- !test_61 --
+0001-03-03
+
+-- !test_62 --
+1900-02-25
+
+-- !test_63 --
+1969-12-29
+
+-- !test_64 --
+9999-12-31
+
+-- !test_65 --
+0000-02-28
+
+-- !test_66 --
+0001-03-01
+
+-- !test_67 --
+1900-02-28
+
+-- !test_68 --
+1970-01-01
+
+-- !test_69 --
+9999-12-31
+
+-- !test_70 --
+0000-03-01
+
+-- !test_71 --
+0000-03-02
+
+-- !test_72 --
+0000-03-03
+
+-- !test_73 --
+\N
+
+-- !test_74 --
+0000-03-01
+
+-- !test_75 --
+\N
+
+-- !test_76 --
+0001-03-01
+
+-- !test_77 --
+\N
+
+-- !test_78 --
+1900-03-01
+
+-- !test_79 --
+1970-02-28
+
+-- !test_80 --
+1970-03-01
+
+-- !test_81 --
+\N
+
+-- !test_82 --
+9999-03-01
+
+-- !test_83 --
+2008-12-29
+
+-- !test_84 --
+2010-01-03
+
+-- !test_85 --
+\N
+
+-- !test_86 --
+2023-04-05
+
+-- !test_101 --
+\N
+
+-- !test_102 --
+0230-01-01
+
+-- !test_103 --
+\N
+
+-- !test_104 --
+\N
+
+-- !test_105 --
+\N
+
+-- !test_106 --
+\N
+
+-- !test_107 --
+\N
+
+-- !test_108 --
+\N
+
+-- !test_109 --
+\N
+
+-- !test_110 --
+\N
+
+-- !test_111 --
+\N
+
+-- !test_112 --
+\N
+
+-- !test_113 --
+\N
+
+-- !test_114 --
+\N
+
+-- !test_115 --
+5555-01-01
+
+-- !test_116 --
+\N
+
+-- !test_116 --
+5555-01-01
+
+-- !test_117 --
+\N
+
+-- !test_118 --
+\N
+
+-- !test_119 --
+\N
+
+-- !test_120 --
+\N
+
+-- !test_87 --
+2023-02-03     2023-02-03      2023-02-03      2023-02-03      2023-02-03      
2023-02-03
+\N     \N      \N      2023-02-03      2023-02-03      2023-02-03
+
+-- !test_88 --
+2023-02-03     2023-02-03      2023-02-03      2023-02-03      2023-02-03      
2023-02-03
+\N     \N      \N      2023-02-03      2023-02-03      2023-02-03
+
+-- !test_89 --
+\N
+\N
+
diff --git 
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_to_iso8601.out
 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_to_iso8601.out
new file mode 100644
index 00000000000..358249891a1
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_to_iso8601.out
@@ -0,0 +1,194 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_1 --
+2023-04-05
+2023-04-05
+2023-04-05
+0000-01-03
+9999-12-31
+\N
+
+-- !test_2 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.000000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.000000
+\N
+
+-- !test_3 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.100000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.900000
+\N
+
+-- !test_4 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.120000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.990000
+\N
+
+-- !test_5 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999000
+\N
+
+-- !test_6 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123400
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999900
+\N
+
+-- !test_7 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123456
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999999
+\N
+
+-- !test_8 --
+2023-04-05
+2023-04-05
+2023-04-05
+0000-01-03
+9999-12-31
+9999-12-31
+
+-- !test_9 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.000000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.000000
+9999-12-31T23:59:59.000000
+
+-- !test_10 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.100000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.900000
+9999-12-31T23:59:59.900000
+
+-- !test_11 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.120000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.990000
+9999-12-31T23:59:59.990000
+
+-- !test_12 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123000
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999000
+9999-12-31T23:59:59.999000
+
+-- !test_13 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123400
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999900
+9999-12-31T23:59:59.999900
+
+-- !test_14 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123456
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999999
+9999-12-31T23:59:59.999999
+
+-- !test_7_2 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123456
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999999
+\N
+
+-- !test_14_2 --
+2023-04-05T03:04:05.000000
+2023-04-05T03:04:05.123456
+2023-04-05T03:04:05.100000
+0000-01-03T00:00:00.000000
+9999-12-31T23:59:59.999999
+9999-12-31T23:59:59.999999
+
+-- !test_14_2 --
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !test_15 --
+2023-01-03
+
+-- !test_16 --
+2023-01-03T00:00:00.000000
+
+-- !test_17 --
+0000-01-03
+
+-- !test_18 --
+0000-01-03T00:00:00.000000
+
+-- !test_19 --
+0000-12-31
+
+-- !test_20 --
+0000-12-31T23:59:59.000000
+
+-- !test_21 --
+0000-02-28
+
+-- !test_22 --
+0000-02-28T00:00:00.000000
+
+-- !test_23 --
+\N
+
+-- !test_24 --
+\N
+
+-- !test_25 --
+1900-02-28
+
+-- !test_26 --
+1900-02-28T00:00:00.000000
+
+-- !test_27 --
+9999-12-31
+
+-- !test_28 --
+9999-12-31T23:59:59.000000
+
+-- !test_29 --
+1970-01-01
+
+-- !test_30 --
+1970-01-01T00:00:00.000000
+
+-- !test_31 --
+1970-01-01
+
+-- !test_32 --
+\N
+
+-- !test_33 --
+\N
+
diff --git 
a/regression-test/data/query_p0/sql_functions/math_functions/test_normal_cdf.out
 
b/regression-test/data/query_p0/sql_functions/math_functions/test_normal_cdf.out
new file mode 100644
index 00000000000..7b500151a9a
--- /dev/null
+++ 
b/regression-test/data/query_p0/sql_functions/math_functions/test_normal_cdf.out
@@ -0,0 +1,201 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_1 --
+0.9750021048517796     0.9750021048517796
+0.5    0.5
+0.0013498980316301035  0.0013498980316301035
+\N     \N
+\N     \N
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+
+-- !test_2 --
+0.9750021048517796     0.9750021048517796
+0.185839346177947      0.185839346177947
+0.9502845653746862     0.9502845653746862
+\N     \N
+\N     \N
+\N     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+
+-- !test_3 --
+0.9750021048517796     0.9750021048517796
+0.8667397370974945     0.8667397370974945
+1.0188922978077164E-4  1.0188922978077164E-4
+\N     \N
+\N     \N
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+
+-- !test_4 --
+0.9750021048517796     0.9750021048517796
+0.5    0.5
+1.488228429380456E-10  1.488228429380456E-10
+0.8413447460685429     0.8413447460685429
+0.8413447460685429     0.8413447460685429
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+
+-- !test_5 --
+0.9750021048517796     0.9750021048517796
+1.0    1.0
+3.1086244689504383E-15 3.1086244689504383E-15
+0.8413447460685429     0.8413447460685429
+0.8413447460685429     0.8413447460685429
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+
+-- !test_6 --
+0.9750021048517796     0.9750021048517796
+4.440892098500626E-16  4.440892098500626E-16
+0.9997299123060366     0.9997299123060366
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+\N     0.9750021048517796
+
+-- !test_7 --
+0.9750021048517796     0.9750021048517796
+0.5861988701119502     0.5861988701119502
+0.8246760551477705     0.8246760551477705
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+0.9750021048517796     0.9750021048517796
+\N     \N
+\N     \N
+\N     \N
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+0.9750021048517796     0.9750021048517796
+
+-- !test_8 --
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+
+-- !test_9 --
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+
+-- !test_10 --
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+
+-- !test_11 --
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+\N     \N
+
+-- !test_12 --
+1      0.0     1.0     0.9750021048517796      0.9750021048517796      
0.9750021048517796
+
+-- !test_13 --
+0.9750021048517796
+
+-- !test_14 --
+0.9750021048517796
+
+-- !test_15 --
+0.9750021048517796
+
+-- !test_16 --
+\N
+
+-- !test_17 --
+\N
+
+-- !test_18 --
+\N
+
+-- !test_19 --
+\N
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.groovy
 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.groovy
new file mode 100644
index 00000000000..52c7bb0da34
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_from_iso8601_date.groovy
@@ -0,0 +1,149 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_from_iso8601_date") {
+
+    def dbName = "test_from_iso8601_date"
+    sql "DROP DATABASE IF EXISTS ${dbName}"
+    sql "CREATE DATABASE ${dbName}"
+    sql "USE $dbName"
+
+
+    qt_test_31 """SELECT from_iso8601_date('0000');"""         // 0000-01-01
+    qt_test_32 """SELECT from_iso8601_date('0001');"""         // 0001-01-01
+    qt_test_33 """SELECT from_iso8601_date('1900');"""         // 1900-01-01
+    qt_test_34 """SELECT from_iso8601_date('1970');"""         // 1970-01-01
+    qt_test_35 """SELECT from_iso8601_date('9999');"""         // 9999-01-01
+
+    qt_test_36 """SELECT from_iso8601_date('0000-01-01');"""   // 0000-01-01
+    qt_test_37 """SELECT from_iso8601_date('0000-02-28');"""   // 0000-02-28
+    qt_test_38 """SELECT from_iso8601_date('0001-02-28');"""   // 0001-02-28
+    qt_test_39 """SELECT from_iso8601_date('1900-02-28');"""   // 1900-02-28
+    qt_test_40 """SELECT from_iso8601_date('1970-01-01');"""   // 1970-01-01
+    qt_test_41 """SELECT from_iso8601_date('9999-12-31');"""   // 9999-12-31
+
+    qt_test_42 """SELECT from_iso8601_date('00000228');"""     // 0000-02-28
+    qt_test_43 """SELECT from_iso8601_date('00010228');"""     // 0001-02-28
+    qt_test_44 """SELECT from_iso8601_date('19000228');"""     // 1900-02-28
+    qt_test_45 """SELECT from_iso8601_date('19700101');"""     // 1970-01-01
+    qt_test_46 """SELECT from_iso8601_date('99991231');"""     // 9999-12-31
+
+    qt_test_47 """SELECT from_iso8601_date('0000-01');"""      // 0000-01-01
+    qt_test_48 """SELECT from_iso8601_date('0000-02');"""      // 0000-02-01
+    qt_test_49 """SELECT from_iso8601_date('0001-03');"""      // 0001-03-01
+    qt_test_50 """SELECT from_iso8601_date('1900-03');"""      // 1900-03-01
+    qt_test_51 """SELECT from_iso8601_date('1970-01');"""      // 1970-01-01
+    qt_test_52 """SELECT from_iso8601_date('9999-12');"""      // 9999-12-01
+
+    qt_test_53 """SELECT from_iso8601_date('0000-W01');"""     // 0000-01-03
+    qt_test_54 """SELECT from_iso8601_date('0000-W09');"""     // 0000-02-28
+    qt_test_55 """SELECT from_iso8601_date('0001-W09');"""     // 0001-02-26
+    qt_test_56 """SELECT from_iso8601_date('1900-W08');"""     // 1900-02-19
+    qt_test_57 """SELECT from_iso8601_date('1970-W01');"""     // 1969-12-29
+    qt_test_58 """SELECT from_iso8601_date('9999-W52');"""     // 9999-12-27
+
+
+    qt_test_59 """SELECT from_iso8601_date('0000-W01-1');"""   // 0000-01-03
+    qt_test_60 """SELECT from_iso8601_date('0000-W09-6');"""   // 0000-03-04   
       0000-03-05 
+    qt_test_61 """SELECT from_iso8601_date('0001-W09-6');"""   // 0001-03-03
+    qt_test_62 """SELECT from_iso8601_date('1900-W08-7');"""   // 1900-02-25
+    qt_test_63 """SELECT from_iso8601_date('1970-W01-1');"""   // 1969-12-29
+    qt_test_64 """SELECT from_iso8601_date('9999-W52-5');"""   // 9999-12-31
+
+
+
+
+    qt_test_65 """SELECT from_iso8601_date('0000-059');"""     // 0000-02-28
+    qt_test_66 """SELECT from_iso8601_date('0001-060');"""     // 0001-03-01
+    qt_test_67 """SELECT from_iso8601_date('1900-059');"""     // 1900-02-28
+    qt_test_68 """SELECT from_iso8601_date('1970-001');"""     // 1970-01-01
+    qt_test_69 """SELECT from_iso8601_date('9999-365');"""     // 9999-12-31
+
+    qt_test_70 """SELECT from_iso8601_date('0000-060');"""     // 0000-02-29   
      0000-03-01
+    qt_test_71 """SELECT from_iso8601_date('0000-061');"""     // 0000-03-01   
      0000-03-02
+    qt_test_72 """SELECT from_iso8601_date('0000-062');"""     // 0000-03-02   
      0000-03-03
+
+    qt_test_73 """SELECT from_iso8601_date('0000-02-29');"""   // 0000-02-29   
      NULL 
+    qt_test_74 """SELECT from_iso8601_date('0000-03-01');"""   // 0000-03-01
+    qt_test_75 """SELECT from_iso8601_date('0001-02-29');"""   // NULL       
+    qt_test_76 """SELECT from_iso8601_date('0001-03-01');"""   // 0001-03-01
+
+    qt_test_77 """SELECT from_iso8601_date('1900-02-29');"""   // NULL
+    qt_test_78 """SELECT from_iso8601_date('1900-03-01');"""   // 1900-03-01
+    qt_test_79 """SELECT from_iso8601_date('1970-02-28');"""   // 1970-02-28
+    qt_test_80 """SELECT from_iso8601_date('1970-03-01');"""   // 1970-03-01
+    qt_test_81 """SELECT from_iso8601_date('9999-02-29');"""   // NULL
+    qt_test_82 """SELECT from_iso8601_date('9999-03-01');"""   // 9999-03-01
+
+    qt_test_83 """SELECT from_iso8601_date('2009-W01-1');"""  // 2008-12-29
+    qt_test_84 """SELECT from_iso8601_date('2009-W53-7')"""          // 
2010-01-03
+
+    qt_test_85 """SELECT from_iso8601_date(NULL);"""
+    qt_test_86 """SELECT from_iso8601_date(nullable("2023-04-05"));"""
+
+
+    qt_test_101 """ SELECT from_iso8601_date("20230");"""
+    qt_test_102 """ SELECT from_iso8601_date("0230");"""
+    qt_test_103 """ SELECT from_iso8601_date("202334");"""
+    qt_test_104 """ SELECT from_iso8601_date("902030");"""
+    qt_test_105 """ SELECT from_iso8601_date("2003--33");"""
+    qt_test_106 """ SELECT from_iso8601_date("abcdd");"""
+    qt_test_107 """ SELECT from_iso8601_date("7855462");"""
+    qt_test_108 """ SELECT from_iso8601_date("010-03-02");"""
+    qt_test_109 """ SELECT from_iso8601_date("2021/03/04");"""
+    qt_test_110 """ SELECT from_iso8601_date("2121W1");"""
+    qt_test_111 """ SELECT from_iso8601_date("2121W00");"""
+    qt_test_112 """ SELECT from_iso8601_date("ssss");"""
+    qt_test_113 """ SELECT from_iso8601_date("5555555");"""
+    qt_test_114 """ SELECT from_iso8601_date("555500");"""
+    qt_test_115 """ SELECT from_iso8601_date("5555001");"""
+    qt_test_116 """ SELECT from_iso8601_date("5555W001");"""
+    qt_test_116 """ SELECT from_iso8601_date("5555-001");"""
+    qt_test_117 """ SELECT from_iso8601_date("5555-W001");"""
+    qt_test_118 """ SELECT from_iso8601_date("555-001");"""
+    qt_test_119 """ SELECT from_iso8601_date("99999-02-01");"""
+    qt_test_120 """ SELECT from_iso8601_date("");"""
+
+
+
+    sql """
+    CREATE TABLE IF NOT EXISTS `tb2` (
+        `k0` int null comment "",
+
+        `k1` string,
+        `k2` char(10),
+        `k3` varchar(10),
+
+        `k11` string  not null ,
+        `k22` char(10) not null ,
+        `k33` varchar(10) not null 
+
+        ) engine=olap
+        DISTRIBUTED BY HASH(`k0`) BUCKETS 5 properties("replication_num" = "1")
+        """
+    sql """insert into tb2 values (1, "2023-02-03","2023-02-03","2023-02-03" , 
 "2023-02-03","2023-02-03","2023-02-03" );"""
+    sql """insert into tb2 values (2, null,null,null,  
"2023-02-03","2023-02-03","2023-02-03" );"""
+
+    qt_test_87  """ select 
from_iso8601_date(k1),from_iso8601_date(k2),from_iso8601_date(k3),from_iso8601_date(k11),from_iso8601_date(k22),from_iso8601_date(k33)
 from tb2 order by  k0;"""
+    qt_test_88 """ select 
from_iso8601_date(nullable(k1)),from_iso8601_date(k2),from_iso8601_date(k3),from_iso8601_date(nullable(k11)),from_iso8601_date(k22),from_iso8601_date(k33)
 from tb2 order by  k0; """ 
+    qt_test_89 """ select from_iso8601_date(NULL)   from tb2 order by  k0; """ 
+
+
+
+    sql """ drop table tb2 """ 
+
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_to_iso8601.groovy
 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_to_iso8601.groovy
new file mode 100644
index 00000000000..55931bd1071
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_to_iso8601.groovy
@@ -0,0 +1,150 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_to_iso8601") {
+
+    def dbName = "test_iso8601"
+    sql "DROP DATABASE IF EXISTS ${dbName}"
+    sql "CREATE DATABASE ${dbName}"
+    sql "USE $dbName"
+    
+    sql """
+        CREATE TABLE IF NOT EXISTS `tb` (
+            `id` int null comment "",
+            
+            `k1`  date   null comment "",
+            `k2` DATETIME null comment "",
+            `k3` DATETIME(1)  null comment "",
+            `k4` DATETIME(2) null comment "",
+            `k5` DATETIME(3) null comment "",
+            `k6` DATETIME(4) null comment "",
+            `k7` DATETIME(6) null comment "",
+
+            `k11` date  not null comment "",
+            `k22` DATETIME not  null comment "",
+            `k33` DATETIME(1) not  null comment "",
+            `k44` DATETIME(2) not null comment "",
+            `k55` DATETIME(3) not null comment "",
+            `k66` DATETIME(4) not null comment "",
+            `k77` DATETIME(6) not null comment ""    
+        ) engine=olap
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 5 properties("replication_num" = "1")
+        """
+
+    sql """ insert into tb values (1,        cast( '2023-04-05' as date ),
+        cast( '2023-04-05 03:04:05' as DATETIME),           cast( '2023-04-05 
03:04:05' as DATETIME(1) ),cast( '2023-04-05 03:04:05' as DATETIME(2) ),cast( 
'2023-04-05 03:04:05' as DATETIME(3) ),
+        cast( '2023-04-05 03:04:05' as DATETIME(4) ),cast( '2023-04-05 
03:04:05' as DATETIME(6) ),
+        cast( '2023-04-05' as date ),
+        cast( '2023-04-05 03:04:05' as DATETIME),           cast( '2023-04-05 
03:04:05' as DATETIME(1) ),cast( '2023-04-05 03:04:05' as DATETIME(2) ),cast( 
'2023-04-05 03:04:05' as DATETIME(3) ),
+        cast( '2023-04-05 03:04:05' as DATETIME(4) ),cast( '2023-04-05 
03:04:05' as DATETIME(6) )
+        );
+        """
+
+    sql """
+        insert into tb values (2,cast( '2023-04-05' as date ),cast( 
'2023-04-05 03:04:05' as DATETIME ),cast( '2023-04-05 03:04:05.1' as 
DATETIME(1) ),cast( '2023-04-05 03:04:05.12' as DATETIME(2) ),
+        cast( '2023-04-05 03:04:05.123' as DATETIME(3) ),cast( '2023-04-05 
03:04:05.1234' as DATETIME(4) ),cast( '2023-04-05 03:04:05.123456' as 
DATETIME(6) ),cast( '2023-04-05' as date ),cast( '2023-04-05 03:04:05' as 
DATETIME ),
+        cast( '2023-04-05 03:04:05.1' as DATETIME(1) ),cast( '2023-04-05 
03:04:05.12' as DATETIME(2) ),cast( '2023-04-05 03:04:05.123' as DATETIME(3) 
),cast( '2023-04-05 03:04:05.1234' as DATETIME(4) ),
+        cast( '2023-04-05 03:04:05.123456' as DATETIME(6) )    
+        ); """ 
+
+    
+    sql  """  
+        insert into tb values   (3,cast( '2023-04-05' as date ),cast( 
'2023-04-05 03:04:05' as DATETIME ),
+        cast( '2023-04-05 03:04:05.1' as DATETIME(1) ),cast( '2023-04-05 
03:04:05.1' as DATETIME(2) ),cast( '2023-04-05 03:04:05.1' as DATETIME(3) ),
+        cast( '2023-04-05 03:04:05.1' as DATETIME(4) ),cast( '2023-04-05 
03:04:05.1' as DATETIME(6) ),cast( '2023-04-05' as date ),cast( '2023-04-05 
03:04:05' as DATETIME ),
+        cast( '2023-04-05 03:04:05.1' as DATETIME(1) ),cast( '2023-04-05 
03:04:05.1' as DATETIME(2) ),cast( '2023-04-05 03:04:05.1' as DATETIME(3) ),
+        cast( '2023-04-05 03:04:05.1' as DATETIME(4) ),cast( '2023-04-05 
03:04:05.1' as DATETIME(6) )    
+        );"""
+    
+    sql """ 
+        insert into tb values (4,CAST('0000-01-03' AS DATE),CAST('0000-01-03 
00:00:00' AS DATETIME),CAST('0000-01-03 00:00:00' AS 
DATETIME(1)),CAST('0000-01-03 00:00:00' AS DATETIME(2)),
+        CAST('0000-01-03 00:00:00' AS DATETIME(3)),CAST('0000-01-03 00:00:00' 
AS DATETIME(4)),CAST('0000-01-03 00:00:00' AS DATETIME(6)),CAST('0000-01-03' AS 
DATE),CAST('0000-01-03 00:00:00' AS DATETIME),
+        CAST('0000-01-03 00:00:00' AS DATETIME(1)),CAST('0000-01-03 00:00:00' 
AS DATETIME(2)),CAST('0000-01-03 00:00:00' AS DATETIME(3)),CAST('0000-01-03 
00:00:00' AS DATETIME(4)),CAST('0000-01-03 00:00:00' AS DATETIME(6))
+        );""" 
+    
+    sql """ 
+        insert into tb values  (5,CAST('9999-12-31' AS DATE),CAST('9999-12-31 
23:59:59' AS DATETIME),CAST('9999-12-31 23:59:59.9' AS DATETIME(1)),
+        CAST('9999-12-31 23:59:59.99' AS DATETIME(2)),CAST('9999-12-31 
23:59:59.999' AS DATETIME(3)),CAST('9999-12-31 23:59:59.9999' AS DATETIME(4)),
+        CAST('9999-12-31 23:59:59.999999' AS DATETIME(6)),CAST('9999-12-31' AS 
DATE),CAST('9999-12-31 23:59:59' AS DATETIME),CAST('9999-12-31 23:59:59.9' AS 
DATETIME(1)),
+        CAST('9999-12-31 23:59:59.99' AS DATETIME(2)),CAST('9999-12-31 
23:59:59.999' AS DATETIME(3)),CAST('9999-12-31 23:59:59.9999' AS 
DATETIME(4)),CAST('9999-12-31 23:59:59.999999' AS DATETIME(6))
+        ); """
+    
+    sql """  
+    insert into tb values  
(6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,CAST('9999-12-31' AS 
DATE),CAST('9999-12-31 23:59:59' AS DATETIME),CAST('9999-12-31 23:59:59.9' AS 
DATETIME(1)),
+    CAST('9999-12-31 23:59:59.99' AS DATETIME(2)),CAST('9999-12-31 
23:59:59.999' AS DATETIME(3)),CAST('9999-12-31 23:59:59.9999' AS 
DATETIME(4)),CAST('9999-12-31 23:59:59.999999' AS DATETIME(6))
+    );
+    """
+
+
+    qt_test_1 """select to_iso8601(k1) from tb order by id;"""
+    qt_test_2 """select to_iso8601(k2) from tb order by id;"""
+    qt_test_3 """select to_iso8601(k3) from tb order by id;"""
+    qt_test_4 """select to_iso8601(k4) from tb order by id;"""
+    qt_test_5 """select to_iso8601(k5) from tb order by id;"""
+    qt_test_6 """select to_iso8601(k6) from tb order by id;"""
+    qt_test_7 """select to_iso8601(k7) from tb order by id;"""
+
+    qt_test_8 """select to_iso8601(k11) from tb order by id;"""
+    qt_test_9  """select to_iso8601(k22) from tb order by id;"""
+    qt_test_10 """select to_iso8601(k33) from tb order by id;"""
+    qt_test_11 """select to_iso8601(k44) from tb order by id;"""
+    qt_test_12 """select to_iso8601(k55) from tb order by id;"""
+    qt_test_13 """select to_iso8601(k66) from tb order by id;"""
+    qt_test_14 """select to_iso8601(k77) from tb order by id;"""
+
+    qt_test_7_2 """select to_iso8601(nullable(k7)) from tb order by id;"""
+    qt_test_14_2 """select to_iso8601(nullable(k77)) from tb order by id;"""
+    qt_test_14_2 """select to_iso8601(NULL) from tb order by id;"""
+
+
+
+    sql """ drop table tb """ 
+
+
+
+    qt_test_15 """SELECT to_iso8601(CAST('2023-01-03' AS DATE));"""
+    qt_test_16 """SELECT to_iso8601(CAST('2023-01-03 00:00:00' AS 
DATETIME));"""
+
+    qt_test_17 """SELECT to_iso8601(CAST('0000-01-03' AS DATE));"""
+    qt_test_18 """SELECT to_iso8601(CAST('0000-01-03 00:00:00' AS 
DATETIME));"""
+
+    qt_test_19 """SELECT to_iso8601(CAST('0000-12-31' AS DATE));"""
+    qt_test_20 """SELECT to_iso8601(CAST('0000-12-31 23:59:59' AS 
DATETIME));"""
+
+    qt_test_21 """SELECT to_iso8601(CAST('0000-02-28' AS DATE));"""
+    qt_test_22 """SELECT to_iso8601(CAST('0000-02-28 00:00:00' AS 
DATETIME));"""
+
+ //  master : CAST('0000-02-29' AS DATE) -> NULL
+ //  2.1    : CAST('0000-02-29' AS DATE) -> Exception 
+ //   qt_test_23 """SELECT to_iso8601(CAST('0000-02-29' AS DATE));"""
+ //   qt_test_24 """SELECT to_iso8601(CAST('0000-02-29 00:00:00' AS 
DATETIME));"""
+
+    qt_test_25 """SELECT to_iso8601(CAST('1900-02-28' AS DATE));"""
+    qt_test_26 """SELECT to_iso8601(CAST('1900-02-28 00:00:00' AS 
DATETIME));"""
+
+    qt_test_27 """SELECT to_iso8601(CAST('9999-12-31' AS DATE));"""
+    qt_test_28 """SELECT to_iso8601(CAST('9999-12-31 23:59:59' AS 
DATETIME));"""
+
+    qt_test_29 """SELECT to_iso8601(CAST('1970-01-01' AS DATE));"""
+    qt_test_30 """SELECT to_iso8601(CAST('1970-01-01 00:00:00' AS 
DATETIME));"""
+
+    qt_test_31 """ SELECT to_iso8601(nullable(CAST('1970-01-01' AS DATE))); """
+    qt_test_32 """ SELECT to_iso8601(nullable(NULL)); """
+    qt_test_33 """ SELECT to_iso8601(NULL); """
+
+
+}
diff --git 
a/regression-test/suites/query_p0/sql_functions/math_functions/test_normal_cdf.groovy
 
b/regression-test/suites/query_p0/sql_functions/math_functions/test_normal_cdf.groovy
new file mode 100644
index 00000000000..8fcd7b0d23d
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/math_functions/test_normal_cdf.groovy
@@ -0,0 +1,93 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_normal_cdf") {
+    def dbName = "test_normal_cdf"
+    sql "DROP DATABASE IF EXISTS ${dbName}"
+    sql "CREATE DATABASE ${dbName}"
+    sql "USE $dbName"
+
+
+    
+    sql """DROP TABLE IF EXISTS `tb`"""
+    sql """ CREATE TABLE `tb` (
+        `id` int ,
+
+        `k1` double ,
+        `k2` double ,
+        `k3` double ,
+
+        `k11` double not NULL,
+        `k22` double not NULL,
+        `k33` double not NULL
+        )
+        DISTRIBUTED BY HASH(`id`) BUCKETS 5 properties("replication_num" = 
"1");
+        """
+
+
+
+    sql """ insert into `tb` values( 1,     0, 1, 1.96,          0, 1, 1.96 ) 
"""  // 0.9750021048517796
+    sql """ insert into `tb` values( 2,     10, 9, 10,          10, 9, 10 ) 
"""  // 0.5
+    sql """ insert into `tb` values( 3,     -1.5, 2.1, -7.8,    -1.5, 2.1, 
-7.8) """  // 0.0013498980316301035
+    
+    sql """ insert into `tb` values( 4,     0 , 0 , 1,          0 , 0 , 1 ) 
"""  // NULL
+    sql """ insert into `tb` values( 5,     0 , -1 , 1,         0 , -1 , 1 ) 
"""  // NULL
+
+
+    sql """ insert into `tb` values( 6,     NULL, NULL, NULL,          0, 1, 
1.96 ) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 7,     0, NULL, NULL,          0, 1, 1.96 
) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 8,     0, 1 , NULL,          0, 1, 1.96 ) 
"""  // 0.9750021048517796
+
+
+    sql """ insert into `tb` values( 9,      0, NULL, 1.96,          0, 1, 
1.96 ) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 10,     0, NULL, NULL,          0, 1, 
1.96 ) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 11,     0, NULL , 1.96,          0, 1, 
1.96 ) """  // 0.9750021048517796
+
+
+    sql """ insert into `tb` values( 12,     NULL, 1, 1.96,          0, 1, 
1.96 ) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 13,     NULL, 1, NULL,          0, 1, 
1.96 ) """  // 0.9750021048517796
+    sql """ insert into `tb` values( 14,     NULL, 1 , 1.96,          0, 1, 
1.96 ) """  // 0.9750021048517796
+
+
+    qt_test_1 """ select normal_cdf(k1,k2,k3),normal_cdf(k11,k22,k33)  from tb 
order by id """  
+
+    qt_test_2 """ select normal_cdf(k1,k2,1.96),normal_cdf(k11,k22,1.96)  from 
tb order by id """  
+    qt_test_3 """ select normal_cdf(0,k2,k3),normal_cdf(0,k22,k33)  from tb 
order by id """  
+    qt_test_4 """ select normal_cdf(k1,1,k3),normal_cdf(k11,1,k33)  from tb 
order by id """  
+
+    qt_test_5 """ select normal_cdf(0,1,k3),normal_cdf(0,1,k33)  from tb order 
by id """  
+    qt_test_6 """ select normal_cdf(k1,1,1.96),normal_cdf(k11,1,1.96)  from tb 
order by id """  
+    qt_test_7 """ select normal_cdf(0,k2,1.96),normal_cdf(0,k2,1.96)  from tb 
order by id """  
+
+    qt_test_8 """ select normal_cdf(k1,k2,NULL),normal_cdf(k11,k22,NULL)  from 
tb order by id """  
+    qt_test_9 """ select normal_cdf(NULL,k2,k3),normal_cdf(NULL,k22,k33)  from 
tb order by id """  
+    qt_test_10 """ select normal_cdf(k1,NULL,k3),normal_cdf(k1,NULL,k33)  from 
tb order by id """  
+
+    qt_test_11 """ select 
normal_cdf(nullable(k1),NULL,k3),normal_cdf(nullable(0),NULL,k33)  from tb 
order by id """  
+
+    qt_test_12 """ select 
id,k1,k2,normal_cdf(0,1,1.96),normal_cdf(k1,k2,1.96),normal_cdf(k11,k22,1.96)  
from tb where id =1 ;"""
+
+    qt_test_13 """ select normal_cdf( 0, 1, 1.96 ) ; """ 
+    qt_test_14 """ select normal_cdf( nullable(0), 1, 1.96 ) ; """ 
+    qt_test_15 """ select normal_cdf( nullable(0), nullable(1), 1.96 ) ; """ 
+    qt_test_16 """ select normal_cdf( nullable(0), NULL  , 1.96 ) ; """     
+    qt_test_17 """ select normal_cdf( nullable(0), NULL  , 1.96 ) ; """
+    qt_test_18 """ select normal_cdf( 0, 1  , NULL ) ; """
+    qt_test_19 """ select normal_cdf( 0, -1,1 ) ; """
+
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to