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 b0c7cfa2000 branch-4.0: [fix](function) str_to_date and
from_iso8601_date return null instead of raise error #57669 (#57699)
b0c7cfa2000 is described below
commit b0c7cfa20009df195d813bc97e0ecf31a49005c1
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Nov 5 00:45:42 2025 +0800
branch-4.0: [fix](function) str_to_date and from_iso8601_date return null
instead of raise error #57669 (#57699)
Cherry-picked from #57669
Co-authored-by: zclllyybb <[email protected]>
---
.../vec/functions/function_other_types_to_date.cpp | 58 +++----
.../doris/catalog/BuiltinScalarFunctions.java | 4 +
.../functions/scalar/FromIso8601Date.java | 4 +-
.../expressions/functions/scalar/StrToDate.java | 4 +-
.../data/correctness/test_str_to_date.out | 16 ++
.../sql-functions/doc_date_functions_test.out | 21 +++
.../data/nereids_function_p0/scalar_function/S.out | 58 +++++++
.../datetime_functions/test_date_function.out | 1 +
.../datetime_functions/test_date_function.out | 6 +
.../datetime_functions/test_from_iso8601_date.out | 114 ++++++++++++++
.../suites/correctness/test_str_to_date.groovy | 40 ++---
.../sql-manual/sql-functions/doc_date_error.groovy | 12 --
.../sql-functions/doc_date_functions_test.groovy | 29 ++--
.../nereids_function_p0/scalar_function/S.groovy | 20 +--
.../datetime_functions/test_date_function.groovy | 10 +-
.../test_from_iso8601_date.groovy | 167 +++++++++------------
16 files changed, 350 insertions(+), 214 deletions(-)
diff --git a/be/src/vec/functions/function_other_types_to_date.cpp
b/be/src/vec/functions/function_other_types_to_date.cpp
index 0d0ba8ffa2b..ec6e506d091 100644
--- a/be/src/vec/functions/function_other_types_to_date.cpp
+++ b/be/src/vec/functions/function_other_types_to_date.cpp
@@ -87,12 +87,9 @@ struct StrToDate {
static bool skip_return_type_check() { return true; }
static DataTypePtr get_return_type_impl(const DataTypes& arguments) {
// it's FAKE. takes no effect.
- return std::make_shared<DataTypeDateTimeV2>(6);
+ return make_nullable(std::make_shared<DataTypeDateTimeV2>(6));
}
- // Handle nulls manually to prevent invalid default values from causing
errors
- static bool use_default_implementation_for_nulls() { return false; }
-
static StringRef rewrite_specific_format(const char* raw_str, size_t
str_size) {
const static std::string specific_format_strs[3] = {"yyyyMMdd",
"yyyy-MM-dd",
"yyyy-MM-dd
HH:mm:ss"};
@@ -110,7 +107,6 @@ struct StrToDate {
static Status execute(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) {
- // Handle null map manually - update result null map from input null
maps upfront
auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
NullMap& result_null_map =
assert_cast<ColumnUInt8&>(*result_null_map_column).get_data();
@@ -121,10 +117,6 @@ struct StrToDate {
for (int i = 0; i < 2; ++i) {
const ColumnPtr& col = block.get_by_position(arguments[i]).column;
col_const[i] = is_column_const(*col);
- const NullMap* null_map = VectorizedUtils::get_null_map(col);
- if (null_map) {
- VectorizedUtils::update_null_map(result_null_map, *null_map,
col_const[i]);
- }
}
// Extract nested columns from const(nullable) wrappers
@@ -132,11 +124,8 @@ struct StrToDate {
*block.get_by_position(arguments[0]).column)
.convert_to_full_column()
:
block.get_by_position(arguments[0]).column;
- argument_columns[0] = remove_nullable(argument_columns[0]);
-
std::tie(argument_columns[1], col_const[1]) =
unpack_if_const(block.get_by_position(arguments[1]).column);
- argument_columns[1] = remove_nullable(argument_columns[1]);
const auto* specific_str_column =
assert_cast<const ColumnString*>(argument_columns[0].get());
@@ -196,7 +185,7 @@ private:
static void execute_impl(
FunctionContext* context, const ColumnString::Chars& ldata,
const ColumnString::Offsets& loffsets, const ColumnString::Chars&
rdata,
- const ColumnString::Offsets& roffsets, const NullMap&
result_null_map,
+ const ColumnString::Offsets& roffsets, NullMap& result_null_map,
PaddedPODArray<typename
PrimitiveTypeTraits<PType>::CppNativeType>& res) {
size_t size = loffsets.size();
res.resize(size);
@@ -212,15 +201,14 @@ private:
size_t r_str_size = roffsets[i] - roffsets[i - 1];
const StringRef format_str = rewrite_specific_format(r_raw_str,
r_str_size);
_execute_inner_loop<PType>(l_raw_str, l_str_size, format_str.data,
format_str.size,
- context, res, i);
+ result_null_map, context, res, i);
}
}
template <PrimitiveType PType>
static void execute_impl_const_right(
FunctionContext* context, const ColumnString::Chars& ldata,
- const ColumnString::Offsets& loffsets, const StringRef& rdata,
- const NullMap& result_null_map,
+ const ColumnString::Offsets& loffsets, const StringRef& rdata,
NullMap& result_null_map,
PaddedPODArray<typename
PrimitiveTypeTraits<PType>::CppNativeType>& res) {
size_t size = loffsets.size();
res.resize(size);
@@ -234,21 +222,20 @@ private:
size_t l_str_size = loffsets[i] - loffsets[i - 1];
_execute_inner_loop<PType>(l_raw_str, l_str_size, format_str.data,
format_str.size,
- context, res, i);
+ result_null_map, context, res, i);
}
}
template <PrimitiveType PType>
static void _execute_inner_loop(
const char* l_raw_str, size_t l_str_size, const char* r_raw_str,
size_t r_str_size,
- FunctionContext* context,
+ NullMap& result_null_map, FunctionContext* context,
PaddedPODArray<typename
PrimitiveTypeTraits<PType>::CppNativeType>& res, size_t index) {
auto& ts_val =
*reinterpret_cast<typename
PrimitiveTypeTraits<PType>::CppType*>(&res[index]);
if (!ts_val.from_date_format_str(r_raw_str, r_str_size, l_raw_str,
l_str_size))
[[unlikely]] {
- throw_invalid_strings("str_to_date", std::string_view(l_raw_str,
l_str_size),
- std::string_view(r_raw_str, r_str_size));
+ result_null_map[index] = 1;
}
}
};
@@ -1222,6 +1209,8 @@ struct FromIso8601DateV2 {
static Status execute(FunctionContext* context, Block& block, const
ColumnNumbers& arguments,
uint32_t result, size_t input_rows_count) {
const auto* src_column_ptr =
block.get_by_position(arguments[0]).column.get();
+ auto result_null_map_column = ColumnUInt8::create(input_rows_count, 0);
+ NullMap& result_null_map =
assert_cast<ColumnUInt8&>(*result_null_map_column).get_data();
ColumnDateV2::MutablePtr res = ColumnDateV2::create(input_rows_count);
auto& result_data = res->get_data();
@@ -1332,32 +1321,32 @@ struct FromIso8601DateV2 {
if (iso_string_format_value == 1) {
if (sscanf(src_string.data(), iso_format_string.data(), &year,
&month, &day) != 3)
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
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]]
{
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
} else if (iso_string_format_value == 2) {
if (sscanf(src_string.data(), iso_format_string.data(), &year,
&month) != 2)
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
if (!(ts_value.template set_time_unit<YEAR>(year) &&
ts_value.template set_time_unit<MONTH>(month)))
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
ts_value.template unchecked_set_time_unit<DAY>(1);
} else if (iso_string_format_value == 3) {
if (sscanf(src_string.data(), iso_format_string.data(), &year)
!= 1) [[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
if (!ts_value.template set_time_unit<YEAR>(year)) [[unlikely]]
{
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
ts_value.template unchecked_set_time_unit<MONTH>(1);
ts_value.template unchecked_set_time_unit<DAY>(1);
@@ -1366,17 +1355,17 @@ struct FromIso8601DateV2 {
if (iso_string_format_value == 5) {
if (sscanf(src_string.data(), iso_format_string.data(),
&year, &week) != 2)
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
} else {
if (sscanf(src_string.data(), iso_format_string.data(),
&year, &week,
&weekday) != 3) [[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
}
// weekday [1,7] week [1,53]
if (weekday < 1 || weekday > 7 || week < 1 || week > 53)
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
auto first_day_of_week = getFirstDayOfISOWeek(year);
@@ -1393,16 +1382,16 @@ struct FromIso8601DateV2 {
} else if (iso_string_format_value == 4) {
if (sscanf(src_string.data(), iso_format_string.data(), &year,
&day_of_year) != 2)
[[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
if (is_leap(year)) {
if (day_of_year < 0 || day_of_year > 366) [[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
} else {
if (day_of_year < 0 || day_of_year > 365) [[unlikely]] {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
}
ts_value.template unchecked_set_time_unit<YEAR>(year);
@@ -1411,10 +1400,11 @@ struct FromIso8601DateV2 {
TimeInterval interval(DAY, day_of_year - 1, false);
ts_value.template date_add_interval<DAY>(interval);
} else {
- throw_invalid_string(name, src_string);
+ result_null_map[i] = 1;
}
}
- block.replace_by_position(result, std::move(res));
+ block.replace_by_position(
+ result, ColumnNullable::create(std::move(res),
std::move(result_null_map_column)));
return Status::OK();
}
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 8b5ea5e5b79..e8d234524ea 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
@@ -514,6 +514,8 @@ import
org.apache.doris.nereids.trees.expressions.functions.scalar.Upper;
import org.apache.doris.nereids.trees.expressions.functions.scalar.UrlDecode;
import org.apache.doris.nereids.trees.expressions.functions.scalar.UrlEncode;
import org.apache.doris.nereids.trees.expressions.functions.scalar.User;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.UtcDate;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.UtcTime;
import
org.apache.doris.nereids.trees.expressions.functions.scalar.UtcTimestamp;
import org.apache.doris.nereids.trees.expressions.functions.scalar.Uuid;
import org.apache.doris.nereids.trees.expressions.functions.scalar.UuidNumeric;
@@ -1057,6 +1059,8 @@ public class BuiltinScalarFunctions implements
FunctionHelper {
scalar(UrlDecode.class, "url_decode"),
scalar(UrlEncode.class, "url_encode"),
scalar(User.class, "user"),
+ scalar(UtcDate.class, "utc_date"),
+ scalar(UtcTime.class, "utc_time"),
scalar(UtcTimestamp.class, "utc_timestamp"),
scalar(Uuid.class, "uuid"),
scalar(UuidNumeric.class, "uuid_numeric"),
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
index d15c8f79bb4..03210adb100 100644
---
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
@@ -19,9 +19,9 @@ 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.functions.PropagateNullLiteral;
-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.DateV2Type;
@@ -37,7 +37,7 @@ import java.util.List;
* ScalarFunction 'from_iso8601_date'. This class is generated by
GenerateFunction.
*/
public class FromIso8601Date extends ScalarFunction
- implements UnaryExpression, ExplicitlyCastableSignature,
PropagateNullLiteral, PropagateNullable {
+ implements UnaryExpression, ExplicitlyCastableSignature,
PropagateNullLiteral, AlwaysNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(DateV2Type.INSTANCE).args(VarcharType.SYSTEM_DEFAULT),
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java
index 1c4ece2f599..6436f439ce5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StrToDate.java
@@ -20,9 +20,9 @@ package
org.apache.doris.nereids.trees.expressions.functions.scalar;
import org.apache.doris.analysis.DateLiteral;
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.functions.PropagateNullLiteral;
-import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
@@ -41,7 +41,7 @@ import java.util.List;
* ScalarFunction 'str_to_date'. This class is generated by GenerateFunction.
*/
public class StrToDate extends ScalarFunction
- implements BinaryExpression, ExplicitlyCastableSignature,
PropagateNullLiteral, PropagateNullable {
+ implements BinaryExpression, ExplicitlyCastableSignature,
PropagateNullLiteral, AlwaysNullable {
// not final signatures. see computeSignature()
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
diff --git a/regression-test/data/correctness/test_str_to_date.out
b/regression-test/data/correctness/test_str_to_date.out
index 22728c8007d..0a3d6e4d814 100644
--- a/regression-test/data/correctness/test_str_to_date.out
+++ b/regression-test/data/correctness/test_str_to_date.out
@@ -19,6 +19,12 @@
-- !const_test4 --
\N
+-- !const_test5 --
+\N
+
+-- !const_test6 --
+\N
+
-- !short_1 --
2023-01-01
@@ -31,6 +37,15 @@
-- !short_4 --
\N
+-- !select_from_table1 --
+1 2019-12-01
+2 \N
+3 2020-12-03
+4 \N
+5 2019-12-01
+6 \N
+7 \N
+
-- !select_from_table2 --
1 2019-12-01T00:00
2 2020-12-03T00:00
@@ -38,4 +53,5 @@
4 \N
5 \N
6 \N
+7 \N
diff --git
a/regression-test/data/doc/sql-manual/sql-functions/doc_date_functions_test.out
b/regression-test/data/doc/sql-manual/sql-functions/doc_date_functions_test.out
index b39bec687e2..50ed96fe59e 100644
---
a/regression-test/data/doc/sql-manual/sql-functions/doc_date_functions_test.out
+++
b/regression-test/data/doc/sql-manual/sql-functions/doc_date_functions_test.out
@@ -419,6 +419,15 @@ Sabtu
-- !from_iso8601_date_5 --
0521-12-29
+-- !from_iso8601_date_6 --
+\N
+
+-- !from_iso8601_date_7 --
+\N
+
+-- !from_iso8601_date_8 --
+\N
+
-- !from_iso8601_date_9 --
\N
@@ -1469,18 +1478,30 @@ da fanadur
-- !str_to_date_3 --
2023-07-13
+-- !str_to_date_4 --
+\N
+
-- !str_to_date_5 --
2004-10-18
-- !str_to_date_6 --
2023-10-05T15:45
+-- !str_to_date_7 --
+\N
+
+-- !str_to_date_8 --
+2023-01-01T10:00
+
-- !str_to_date_9 --
2023-07-13T12:34:56.789
-- !str_to_date_10 --
\N \N
+-- !str_to_date_11 --
+\N
+
-- !timediff_1 --
216:24:09
diff --git a/regression-test/data/nereids_function_p0/scalar_function/S.out
b/regression-test/data/nereids_function_p0/scalar_function/S.out
index b93aa93a0b1..96c7342bf11 100644
--- a/regression-test/data/nereids_function_p0/scalar_function/S.out
+++ b/regression-test/data/nereids_function_p0/scalar_function/S.out
@@ -2350,6 +2350,64 @@ true
true
true
+-- !sql_str_to_date_Varchar_Varchar --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !sql_str_to_date_Varchar_Varchar_notnull --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !sql_str_to_date_String_String --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
+-- !sql_str_to_date_String_String_notnull --
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+\N
+
-- !sql_strleft_Varchar_Integer --
\N
v
diff --git
a/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
b/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
index c18f2b7ec4c..c7ba4bf7f9e 100644
---
a/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
+++
b/regression-test/data/nereids_p0/sql_functions/datetime_functions/test_date_function.out
@@ -857,3 +857,4 @@ true
\N \N
\N \N
\N \N
+
diff --git
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
index e38c206d81c..c9117deab3f 100644
---
a/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
+++
b/regression-test/data/query_p0/sql_functions/datetime_functions/test_date_function.out
@@ -306,6 +306,9 @@ February
-- !sql --
2014-12-21T12:34:56
+-- !sql --
+\N
+
-- !sql --
2014-12-21T12:34:56
@@ -607,6 +610,9 @@ true
-- !sql --
2022 31 4
+-- !sql --
+\N
+
-- !sql --
2022-07-12T20:00:45
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
index cceef887de6..93b8bda36e1 100644
---
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
@@ -125,12 +125,21 @@
-- !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
@@ -140,6 +149,9 @@
-- !test_80 --
1970-03-01
+-- !test_81 --
+\N
+
-- !test_82 --
9999-03-01
@@ -155,6 +167,69 @@
-- !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
@@ -174,9 +249,48 @@
4 1970-01-01
5 9999-12-31
6 1000-01-01
+7 \N
+8 \N
+9 \N
+10 \N
+11 \N
12 2023-02-28
13 2024-02-29
+14 \N
+15 \N
+16 \N
+17 \N
+18 \N
+19 \N
20 2023-01-01
+21 \N
+22 \N
+23 \N
24 2023-01-02
25 2023-01-01
+26 \N
+27 \N
+28 \N
+29 \N
+30 \N
+31 \N
+32 \N
+33 \N
+34 \N
+35 \N
+36 \N
+37 \N
+38 \N
+39 \N
+40 \N
+41 \N
+42 \N
+43 \N
+44 \N
+45 \N
+46 \N
+47 \N
+48 \N
+49 \N
+50 \N
diff --git a/regression-test/suites/correctness/test_str_to_date.groovy
b/regression-test/suites/correctness/test_str_to_date.groovy
index c4121e6363c..7ccc9fa0ae0 100644
--- a/regression-test/suites/correctness/test_str_to_date.groovy
+++ b/regression-test/suites/correctness/test_str_to_date.groovy
@@ -38,7 +38,7 @@ suite("test_str_to_date") {
sql """ INSERT INTO test_str_to_date_db VALUES(4,null, 'yyyy-MM-dd');"""
sql """ INSERT INTO test_str_to_date_db VALUES(5,'2019-12-01', null);"""
sql """ INSERT INTO test_str_to_date_db VALUES(6,null, null);"""
- // sql """ INSERT INTO test_str_to_date_db VALUES(7,'无效日期',
'yyyy-MM-dd');"""
+ sql """ INSERT INTO test_str_to_date_db VALUES(7,'无效日期', 'yyyy-MM-dd');"""
qt_select1 """
select id, s1, s2, STR_TO_DATE(s1, s2) from test_str_to_date_db
@@ -57,31 +57,18 @@ suite("test_str_to_date") {
qt_const_test4 """
SELECT STR_TO_DATE(null, null);
"""
- test {
- sql "select STR_TO_DATE('无效日期', 'yyyy-MM-dd')"
- exception "is invalid"
- }
-
- test {
- sql "SELECT /*+SET_VAR(debug_skip_fold_constant=false)
*/STR_TO_DATE('09:30:17', '%h:%i:%s');"
- exception "is invalid"
- }
- test {
- sql "SELECT /*+SET_VAR(debug_skip_fold_constant=true)
*/STR_TO_DATE('09:30:17', '%h:%i:%s');"
- exception "is invalid"
- }
+ qt_const_test5 "select STR_TO_DATE('无效日期', 'yyyy-MM-dd')"
+ qt_const_test6 "SELECT STR_TO_DATE('09:30:17', '%h:%i:%s');"
+ testFoldConst("SELECT STR_TO_DATE('09:30:17', '%h:%i:%s');")
qt_short_1 " select STR_TO_DATE('2023', '%Y') "
qt_short_2 " select STR_TO_DATE(null, '%Y') "
qt_short_3 " select STR_TO_DATE('2023', null) "
qt_short_4 " select STR_TO_DATE(null, null) "
- test {
- sql """
- SELECT id, STR_TO_DATE(s1, '%Y-%m-%d') as result from
test_str_to_date_db order by id;
- """
- exception "is invalid"
- }
+ qt_select_from_table1 """
+ SELECT id, STR_TO_DATE(s1, '%Y-%m-%d') as result from
test_str_to_date_db order by id;
+ """
qt_select_from_table2 """
SELECT id, STR_TO_DATE(s1, s2) as result from test_str_to_date_db
order by id;
"""
@@ -90,15 +77,6 @@ suite("test_str_to_date") {
check_fold_consistency "STR_TO_DATE(null, 'yyyy-MM-dd')"
check_fold_consistency "STR_TO_DATE('2019-12-01', null)"
check_fold_consistency "STR_TO_DATE(null, null)"
-
- test {
- sql """
- SELECT STR_TO_DATE(' ', '%Y-%m-%d %H:%i:%s');
- """
- exception "is invalid"
- }
- test {
- sql "SELECT str_to_date('2022-09-18 00:00:59','%Y-%m-%d %H:%M:%S')"
- exception "%Y-%m-%d %H:%M:%S is invalid"
- }
+ check_fold_consistency "STR_TO_DATE(' ', '%Y-%m-%d %H:%i:%s')"
+ check_fold_consistency "str_to_date('2022-09-18 00:00:59','%Y-%m-%d
%H:%M:%S')"
}
diff --git
a/regression-test/suites/doc/sql-manual/sql-functions/doc_date_error.groovy
b/regression-test/suites/doc/sql-manual/sql-functions/doc_date_error.groovy
index 79c207eeaf0..866a8879cd5 100644
--- a/regression-test/suites/doc/sql-manual/sql-functions/doc_date_error.groovy
+++ b/regression-test/suites/doc/sql-manual/sql-functions/doc_date_error.groovy
@@ -105,12 +105,6 @@ suite("doc_date_error") {
exception "Operation from_days of 99999999 out of range"
}
- // from_iso8601_date format error
- test {
- sql """select from_iso8601_date('2023-10-01T12:34:10');"""
- exception "Operation from_iso8601_date of 2023-10-01T12:34:10 is
invalid"
- }
-
// from_microsecond input is negative
test {
sql """select from_microsecond(-1);"""
@@ -363,12 +357,6 @@ suite("doc_date_error") {
exception "Operation second_add of 0000-01-01 00:00:00, -1 out of
range"
}
- // STR_TO_DATE format mismatch
- test {
- sql """SELECT STR_TO_DATE('2023/01/01', '%Y-%m-%d') AS result;"""
- exception "Operation str_to_date of 2023/01/01, %Y-%m-%d is invalid"
- }
-
// TIMESTAMPADD invalid unit
test {
sql """SELECT TIMESTAMPADD(MIN, 5, '2023-01-01') AS result;"""
diff --git
a/regression-test/suites/doc/sql-manual/sql-functions/doc_date_functions_test.groovy
b/regression-test/suites/doc/sql-manual/sql-functions/doc_date_functions_test.groovy
index 05a8576b178..ad3687d63eb 100644
---
a/regression-test/suites/doc/sql-manual/sql-functions/doc_date_functions_test.groovy
+++
b/regression-test/suites/doc/sql-manual/sql-functions/doc_date_functions_test.groovy
@@ -469,22 +469,23 @@ suite("doc_date_functions_test") {
qt_extract_3 """select extract(week from '2024-01-06') as week"""
qt_extract_4 """select extract(week from '2024-01-07') as week"""
qt_extract_5 """select extract(week from '2024-12-31') as week"""
-
+
// 20. FROM_DAYS function tests
qt_from_days_1 """select from_days(730669),from_days(5),from_days(59),
from_days(60)"""
// qt_from_days_2 """select from_days(-60)"""
qt_from_days_3 """select from_days(NULL)"""
-
+
// 21. FROM_ISO8601_DATE function tests
qt_from_iso8601_date_1 """select from_iso8601_date('2023') as year_only,
from_iso8601_date('2023-10') as year_month, from_iso8601_date('2023-10-05') as
full_date"""
qt_from_iso8601_date_2 """select from_iso8601_date('2021-001') as day_1,
from_iso8601_date('2021-059') as day_59, from_iso8601_date('2021-060') as
day_60, from_iso8601_date('2024-366') as day_366"""
qt_from_iso8601_date_3 """select from_iso8601_date('0522-W01-1') as
week_1"""
qt_from_iso8601_date_4 """select from_iso8601_date('0522-W01-4') as
week_4"""
qt_from_iso8601_date_5 """select from_iso8601_date('0522-W01') as week_1"""
- // qt_from_iso8601_date_6 """select
from_iso8601_date('2023-10-01T12:34:10')"""
- // qt_from_iso8601_date_7 """select from_iso8601_date('0522-W61') as
week_61"""
- // qt_from_iso8601_date_8 """select from_iso8601_date('0522-661') as
day_661"""
+ qt_from_iso8601_date_6 """select
from_iso8601_date('2023-10-01T12:34:10')"""
+ qt_from_iso8601_date_7 """select from_iso8601_date('0522-W61') as
week_61"""
+ qt_from_iso8601_date_8 """select from_iso8601_date('0522-661') as
day_661"""
qt_from_iso8601_date_9 """select from_iso8601_date(NULL)"""
+ sql """select from_iso8601_date('2023-10-01T12:34:10');"""
// 22. FROM_MICROSECOND function tests
qt_from_microsecond_1 """SELECT FROM_MICROSECOND(0)"""
@@ -1135,14 +1136,14 @@ suite("doc_date_functions_test") {
qt_str_to_date_1 """SELECT STR_TO_DATE('2025-01-23 12:34:56', '%Y-%m-%d
%H:%i:%s')"""
qt_str_to_date_2 """SELECT STR_TO_DATE('2025-01-23 12:34:56', 'yyyy-MM-dd
HH:mm:ss')"""
qt_str_to_date_3 """SELECT STR_TO_DATE('20230713', 'yyyyMMdd')"""
- // qt_str_to_date_4 """SELECT STR_TO_DATE('15:30:45', '%H:%i:%s')"""
+ qt_str_to_date_4 """SELECT STR_TO_DATE('15:30:45', '%H:%i:%s')"""
qt_str_to_date_5 """SELECT STR_TO_DATE('200442 Monday', '%X%V %W')"""
qt_str_to_date_6 """SELECT STR_TO_DATE('Oct 5 2023 3:45:00 PM', '%b %d %Y
%h:%i:%s %p')"""
- // qt_str_to_date_7 """SELECT STR_TO_DATE('2023/01/01', '%Y-%m-%d')"""
- // qt_str_to_date_8 """SELECT STR_TO_DATE('2023-01-01 10:00:00 (GMT)',
'%Y-%m-%d %H:%i:%s')"""
+ qt_str_to_date_7 """SELECT STR_TO_DATE('2023/01/01', '%Y-%m-%d')"""
+ qt_str_to_date_8 """SELECT STR_TO_DATE('2023-01-01 10:00:00 (GMT)',
'%Y-%m-%d %H:%i:%s')"""
qt_str_to_date_9 """SELECT STR_TO_DATE('2023-07-13 12:34:56.789',
'%Y-%m-%d %H:%i:%s.%f')"""
qt_str_to_date_10 """SELECT STR_TO_DATE(NULL, '%Y-%m-%d'),
STR_TO_DATE('2023-01-01', NULL)"""
- // qt_str_to_date_11 """SELECT STR_TO_DATE('2023-01-01', '')"""
+ qt_str_to_date_11 """SELECT STR_TO_DATE('2023-01-01', '')"""
// 72. TIMEDIFF function tests
qt_timediff_1 """SELECT TIMEDIFF('2024-07-20 16:59:30', '2024-07-11
16:35:21')"""
@@ -1539,9 +1540,9 @@ suite("doc_date_functions_test") {
testFoldConst("SELECT FROM_ISO8601_DATE('2021-060') as day_60")
testFoldConst("SELECT FROM_ISO8601_DATE('2024-366') as day_366")
testFoldConst("SELECT FROM_ISO8601_DATE('0522-W01-1') as week_1")
- // testFoldConst("SELECT FROM_ISO8601_DATE('2023-10-01T12:34:10')")
- // testFoldConst("SELECT FROM_ISO8601_DATE('0522-661') as day_661")
- // testFoldConst("SELECT FROM_ISO8601_DATE('invalid-date')")
+ testFoldConst("SELECT FROM_ISO8601_DATE('2023-10-01T12:34:10')")
+ testFoldConst("SELECT FROM_ISO8601_DATE('0522-661') as day_661")
+ testFoldConst("SELECT FROM_ISO8601_DATE('invalid-date')")
testFoldConst("SELECT FROM_ISO8601_DATE(NULL)")
// 22. FROM_MILLISECOND function constant folding tests
@@ -1834,12 +1835,12 @@ suite("doc_date_functions_test") {
testFoldConst("SELECT STR_TO_DATE('2025-01-23 12:34:56', '%Y-%m-%d
%H:%i:%s')")
testFoldConst("SELECT STR_TO_DATE('2025-01-23 12:34:56', 'yyyy-MM-dd
HH:mm:ss')")
testFoldConst("SELECT STR_TO_DATE('20230713', 'yyyyMMdd')")
- // testFoldConst("SELECT STR_TO_DATE('15:30:45', '%H:%i:%s')")
+ testFoldConst("SELECT STR_TO_DATE('15:30:45', '%H:%i:%s')")
testFoldConst("SELECT STR_TO_DATE('200442 Monday', '%X%V %W')")
testFoldConst("SELECT STR_TO_DATE('Oct 5 2023 3:45:00 PM', '%b %d %Y
%h:%i:%s %p')")
testFoldConst("SELECT STR_TO_DATE('2023-01-01 10:00:00 (GMT)', '%Y-%m-%d
%H:%i:%s')")
testFoldConst("SELECT STR_TO_DATE('2023-07-13 12:34:56.789', '%Y-%m-%d
%H:%i:%s.%f')")
- // testFoldConst("SELECT STR_TO_DATE('2023-01-01', '')")
+ testFoldConst("SELECT STR_TO_DATE('2023-01-01', '')")
// 72. TIMEDIFF function constant folding tests
testFoldConst("SELECT TIMEDIFF('2024-07-20 16:59:30', '2024-07-11
16:35:21')")
diff --git
a/regression-test/suites/nereids_function_p0/scalar_function/S.groovy
b/regression-test/suites/nereids_function_p0/scalar_function/S.groovy
index c3b8b179e70..e5c4aaf3ad6 100644
--- a/regression-test/suites/nereids_function_p0/scalar_function/S.groovy
+++ b/regression-test/suites/nereids_function_p0/scalar_function/S.groovy
@@ -213,22 +213,10 @@ suite("nereids_scalar_fn_S") {
qt_sql_starts_with_Varchar_Varchar_notnull "select starts_with(kvchrs1,
kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1"
qt_sql_starts_with_String_String "select starts_with(kstr, kstr) from
fn_test order by kstr, kstr"
qt_sql_starts_with_String_String_notnull "select starts_with(kstr,
kstr) from fn_test_not_nullable order by kstr, kstr"
- test{
- sql "select str_to_date(kvchrs1, kvchrs1) from fn_test order by
kvchrs1, kvchrs1"
- exception "is invalid"
- }
- test{
- sql "select str_to_date(kvchrs1, kvchrs1) from
fn_test_not_nullable order by kvchrs1, kvchrs1"
- exception "is invalid"
- }
- test{
- sql "select str_to_date(kstr, kstr) from fn_test order by kstr,
kstr"
- exception "is invalid"
- }
- test{
- sql "select str_to_date(kstr, kstr) from fn_test_not_nullable
order by kstr, kstr"
- exception "is invalid"
- }
+ qt_sql_str_to_date_Varchar_Varchar "select str_to_date(kvchrs1,
kvchrs1) from fn_test order by kvchrs1, kvchrs1"
+ qt_sql_str_to_date_Varchar_Varchar_notnull "select str_to_date(kvchrs1,
kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1"
+ qt_sql_str_to_date_String_String "select str_to_date(kstr, kstr) from
fn_test order by kstr, kstr"
+ qt_sql_str_to_date_String_String_notnull "select str_to_date(kstr,
kstr) from fn_test_not_nullable order by kstr, kstr"
qt_sql_strleft_Varchar_Integer "select strleft(kvchrs1, kint) from
fn_test order by kvchrs1, kint"
qt_sql_strleft_Varchar_Integer_notnull "select strleft(kvchrs1, kint)
from fn_test_not_nullable order by kvchrs1, kint"
qt_sql_strleft_String_Integer "select strleft(kstr, kint) from fn_test
order by kstr, kint"
diff --git
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
index 542b8778d63..e0c87139eba 100644
---
a/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
+++
b/regression-test/suites/query_p0/sql_functions/datetime_functions/test_date_function.groovy
@@ -436,10 +436,7 @@ suite("test_date_function") {
sql """ truncate table ${tableName} """
sql """ insert into ${tableName} values ("2014-12-21 12:34:56") """
qt_sql """ select str_to_date(test_datetime, '%Y-%m-%d %H:%i:%s') from
${tableName}; """
- test {
- sql """ select str_to_date("", "%Y-%m-%d %H:%i:%s"); """
- exception "is invalid"
- }
+ qt_sql """ select str_to_date("", "%Y-%m-%d %H:%i:%s"); """
qt_sql """ select str_to_date("2014-12-21 12:34%3A56", '%Y-%m-%d
%H:%i%%3A%s'); """
qt_sql """ select str_to_date('11.09.2011 11:09:30', '%m.%d.%Y %h:%i:%s');
"""
qt_sql """ select str_to_date("2014-12-21 12:34:56.789 PM", '%Y-%m-%d
%h:%i:%s.%f %p'); """
@@ -624,10 +621,7 @@ suite("test_date_function") {
qt_sql """ select date_format('1999-01-01', '%X %V'); """
qt_sql """ select date_format('2025-01-01', '%X %V'); """
qt_sql """ select date_format('2022-08-04', '%X %V %w'); """
- test {
- sql """ select STR_TO_DATE('Tue Jul 12 20:00:45 CST 2022', '%a %b %e
%H:%i:%s %Y'); """
- exception "is invalid"
- }
+ qt_sql """ select STR_TO_DATE('Tue Jul 12 20:00:45 CST 2022', '%a %b %e
%H:%i:%s %Y'); """
qt_sql """ select STR_TO_DATE('Tue Jul 12 20:00:45 CST 2022', '%a %b %e %T
CST %Y'); """
qt_sql """ select STR_TO_DATE('2018-4-2 15:3:28','%Y-%m-%d %H:%i:%s'); """
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
index 32085c378f8..79d508cae87 100644
---
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
@@ -77,28 +77,16 @@ suite("test_from_iso8601_date") {
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
- test {
- sql """SELECT from_iso8601_date('0000-02-29');""" // 0000-02-29
NULL
- exception "is invalid"
- }
+ 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
- test {
- sql """SELECT from_iso8601_date('0001-02-29');""" // NULL
- exception "is invalid"
- }
+ qt_test_75 """SELECT from_iso8601_date('0001-02-29');""" // NULL
qt_test_76 """SELECT from_iso8601_date('0001-03-01');""" // 0001-03-01
- test {
- sql """SELECT from_iso8601_date('1900-02-29');""" // NULL
- exception "is invalid"
- }
+ 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
- test {
- sql """SELECT from_iso8601_date('9999-02-29');""" // NULL
- exception "is invalid"
- }
+ 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
@@ -107,28 +95,28 @@ suite("test_from_iso8601_date") {
qt_test_85 """SELECT from_iso8601_date(NULL);"""
qt_test_86 """SELECT from_iso8601_date(nullable("2023-04-05"));"""
- // add when support try
- // 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("");"""
+
+ 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("");"""
@@ -156,61 +144,7 @@ suite("test_from_iso8601_date") {
sql """
- CREATE TABLE tb3 (id INT, date_str VARCHAR(255)) DISTRIBUTED BY HASH(id)
BUCKETS 4 PROPERTIES ("replication_num" = "1");
- """
- // sql """
- // INSERT INTO tb3 (id, date_str) VALUES
- // (1, '2023-01-01'),
- // (2, '2023-12-31'),
- // (3, '2020-02-29'),
- // (4, '1970-01-01'),
- // (5, '9999-12-31'),
- // (6, '1000-01-01'),
- // (7, '2023-13-01'),
- // (8, '2023-00-01'),
- // (9, '2023-01-00'),
- // (10, '2023-01-32'),
- // (11, '2023-02-29'),
- // (12, '2023-02-28'),
- // (13, '2024-02-29'),
- // (14, '2024-02-30'),
- // (15, '2023-01-01T12:00:00'),
- // (16, '2023-01-01 12:00:00'),
- // (17, '2023/01/01'),
- // (18, '01-01-2023'),
- // (19, '01/01/2023'),
- // (20, '20230101'),
- // (21, '2023-01-01Z'),
- // (22, '2023-01-01+08:00'),
- // (23, '2023-01-01-08:00'),
- // (24, '2023-W01-1'),
- // (25, '2023-001'),
- // (26, '2023-01-01T12:00:00.000Z'),
- // (27, '2023-01-01T12:00:00.000+08:00'),
- // (28, '2023-01-01T12:00:00.000-08:00'),
- // (29, '2023-01-01T12:00:00.123456Z'),
- // (30, '2023-01-01T12:00:00.123456+08:00'),
- // (31, '2023-01-01T12:00:00.123456-08:00'),
- // (32, '2023-01-01T24:00:00'),
- // (33, '2023-01-01T00:00:00.000000'),
- // (34, '2023-01-01T00:00:00.000001'),
- // (35, '2023-01-01T00:00:00.999999'),
- // (36, '2023-01-01T23:59:59.999999'),
- // (37, '2023-01-01T23:59:60'),
- // (38, '2023-01-01T23:59:59.9999999'),
- // (39, '2023-01-01T23:59:59.999999999'),
- // (40, '2023-01-01T23:59:59.999999999Z'),
- // (41, '2023-01-01T23:59:59.999999999+08:00'),
- // (42, '2023-01-01T23:59:59.999999999-08:00'),
- // (43, '2023-01-01T23:59:59.999999999999'),
- // (44, '2023-01-01T23:59:59.999999999999Z'),
- // (45, '2023-01-01T23:59:59.999999999999+08:00'),
- // (46, '2023-01-01T23:59:59.999999999999-08:00'),
- // (47, '2023-01-01T23:59:59.999999999999999'),
- // (48, '2023-01-01T23:59:59.999999999999999Z'),
- // (49, '2023-01-01T23:59:59.999999999999999+08:00'),
- // (50, '2023-01-01T23:59:59.999999999999999-08:00');
- // """
+ CREATE TABLE tb3 (id INT, date_str VARCHAR(255)) DISTRIBUTED BY HASH(id)
BUCKETS 4 PROPERTIES ("replication_num" = "1"); """
sql """
INSERT INTO tb3 (id, date_str) VALUES
(1, '2023-01-01'),
@@ -219,12 +153,55 @@ suite("test_from_iso8601_date") {
(4, '1970-01-01'),
(5, '9999-12-31'),
(6, '1000-01-01'),
+ (7, '2023-13-01'),
+ (8, '2023-00-01'),
+ (9, '2023-01-00'),
+ (10, '2023-01-32'),
+ (11, '2023-02-29'),
(12, '2023-02-28'),
(13, '2024-02-29'),
+ (14, '2024-02-30'),
+ (15, '2023-01-01T12:00:00'),
+ (16, '2023-01-01 12:00:00'),
+ (17, '2023/01/01'),
+ (18, '01-01-2023'),
+ (19, '01/01/2023'),
(20, '20230101'),
+ (21, '2023-01-01Z'),
+ (22, '2023-01-01+08:00'),
+ (23, '2023-01-01-08:00'),
(24, '2023-W01-1'),
- (25, '2023-001')
-;
+ (25, '2023-001'),
+ (26, '2023-01-01T12:00:00.000Z'),
+ (27, '2023-01-01T12:00:00.000+08:00'),
+ (28, '2023-01-01T12:00:00.000-08:00'),
+ (29, '2023-01-01T12:00:00.123456Z'),
+ (30, '2023-01-01T12:00:00.123456+08:00'),
+ (31, '2023-01-01T12:00:00.123456-08:00'),
+ (32, '2023-01-01T24:00:00'),
+ (33, '2023-01-01T00:00:00.000000'),
+ (34, '2023-01-01T00:00:00.000001'),
+ (35, '2023-01-01T00:00:00.999999'),
+ (36, '2023-01-01T23:59:59.999999'),
+ (37, '2023-01-01T23:59:60'),
+ (38, '2023-01-01T23:59:59.9999999'),
+ (39, '2023-01-01T23:59:59.999999999'),
+ (40, '2023-01-01T23:59:59.999999999Z'),
+ (41, '2023-01-01T23:59:59.999999999+08:00'),
+ (42, '2023-01-01T23:59:59.999999999-08:00'),
+ (43, '2023-01-01T23:59:59.999999999999'),
+ (44, '2023-01-01T23:59:59.999999999999Z'),
+ (45, '2023-01-01T23:59:59.999999999999+08:00'),
+ (46, '2023-01-01T23:59:59.999999999999-08:00'),
+ (47, '2023-01-01T23:59:59.999999999999999'),
+ (48, '2023-01-01T23:59:59.999999999999999Z'),
+ (49, '2023-01-01T23:59:59.999999999999999+08:00'),
+ (50, '2023-01-01T23:59:59.999999999999999-08:00');
"""
qt_test_99 """ SELECT id, from_iso8601_date(date_str) AS result FROM tb3
order by id; """
+
+
+
+ sql """ drop table tb2 """
+
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]