This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch 2.1_35863 in repository https://gitbox.apache.org/repos/asf/doris.git
commit d1f0f9ee3bb32e3b63c65d62564b52692be73e58 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Wed Jun 5 22:11:06 2024 +0800 [opt](Nereids) use date signature for date arithmetic as far as possible pick from master #35863 if date arithmetic (date_add / date_sub)'s first argument is StringLikeLiteral. We use date signature as far as possible. for example: SQL: `select date_sub('2024-05-28', INTERVAL 1 week);` before this PR: ``` +------------------------------------------------+ | weeks_sub(cast('2024-05-28' as DATETIMEV2), 1) | +------------------------------------------------+ | 2024-05-21 00:00:00 | +------------------------------------------------+ ``` after this PR: ``` +--------------------------------------------+ | weeks_sub(cast('2024-05-28' as DATEV2), 1) | +--------------------------------------------+ | 2024-05-21 | +--------------------------------------------+ ``` --- .../ComputeSignatureForDateArithmetic.java | 59 ++++++ .../expressions/functions/scalar/DaysAdd.java | 4 +- .../expressions/functions/scalar/DaysSub.java | 4 +- .../expressions/functions/scalar/MonthsAdd.java | 15 +- .../expressions/functions/scalar/MonthsSub.java | 15 +- .../expressions/functions/scalar/WeeksAdd.java | 4 +- .../expressions/functions/scalar/WeeksSub.java | 4 +- .../expressions/functions/scalar/YearsAdd.java | 15 +- .../expressions/functions/scalar/YearsSub.java | 15 +- .../apache/doris/planner/ConstantExpressTest.java | 4 +- .../fold_constant/fold_constant_by_fe.out | 200 ++++++++++----------- .../data/nereids_syntax_p0/test_date_add.out | 28 +-- .../data/nereids_syntax_p0/test_date_sub.out | 24 +-- 13 files changed, 251 insertions(+), 140 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java new file mode 100644 index 00000000000..c5aa4caae54 --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java @@ -0,0 +1,59 @@ +// 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; + +import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.common.Config; +import org.apache.doris.nereids.annotation.Developing; +import org.apache.doris.nereids.trees.expressions.literal.DateV2Literal; +import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral; +import org.apache.doris.nereids.types.DateType; +import org.apache.doris.nereids.types.DateV2Type; +import org.apache.doris.nereids.types.IntegerType; + +/** + * use for date arithmetic, such as date_sub('2024-05-28', INTERVAL 1 day). + * if the first argument is string like literal and could cast to legal date literal, + * then use date/dateV2 signature + */ +@Developing +public interface ComputeSignatureForDateArithmetic extends ComputeSignature { + + @Override + default FunctionSignature computeSignature(FunctionSignature signature) { + FunctionSignature ret = ComputeSignature.super.computeSignature(signature); + if (child(0) instanceof StringLikeLiteral) { + try { + String s = ((StringLikeLiteral) child(0)).getStringValue().trim(); + // avoid use date/dateV2 signature for '2020-02-02 00:00:00' + if (s.length() <= 10) { + new DateV2Literal(s); + if (Config.enable_date_conversion) { + return FunctionSignature.ret(DateV2Type.INSTANCE) + .args(DateV2Type.INSTANCE, IntegerType.INSTANCE); + } else { + return FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE); + } + } + } catch (Exception e) { + // string like literal cannot cast to a legal date/dateV2 literal + } + } + return ret; + } +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysAdd.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysAdd.java index a5eb3e53f26..e02c20eee82 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysAdd.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysAdd.java @@ -20,6 +20,7 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -39,7 +40,8 @@ import java.util.List; * ScalarFunction 'days_add'. */ public class DaysAdd extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { // When enable_date_conversion is true, we prefer to V2 signature. // This preference follows original planner. refer to ScalarType.getDefaultDateType() private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysSub.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysSub.java index 09e79fb0725..8d135dc6c9c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysSub.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysSub.java @@ -20,6 +20,7 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -39,7 +40,8 @@ import java.util.List; * ScalarFunction 'days_sub'. */ public class DaysSub extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { // When enable_date_conversion is true, we prefer to V2 signature. // This preference follows original planner. refer to ScalarType.getDefaultDateType() private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsAdd.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsAdd.java index c11534e931f..5126400b71e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsAdd.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsAdd.java @@ -18,7 +18,9 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -38,14 +40,23 @@ import java.util.List; * ScalarFunction 'months_add'. */ public class MonthsAdd extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { - private static final List<FunctionSignature> SIGNATURES = ImmutableList.of( + // When enable_date_conversion is true, we prefer to V2 signature. + // This preference follows original planner. refer to ScalarType.getDefaultDateType() + private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE) + ) : ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) + .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) ); public MonthsAdd(Expression arg0, Expression arg1) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsSub.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsSub.java index 279cd3af6df..1c2985a6e13 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsSub.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthsSub.java @@ -18,7 +18,9 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -38,14 +40,23 @@ import java.util.List; * ScalarFunction 'months_sub'. */ public class MonthsSub extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { - private static final List<FunctionSignature> SIGNATURES = ImmutableList.of( + // When enable_date_conversion is true, we prefer to V2 signature. + // This preference follows original planner. refer to ScalarType.getDefaultDateType() + private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE) + ) : ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) + .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) ); public MonthsSub(Expression arg0, Expression arg1) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksAdd.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksAdd.java index 3cfd6e8c6f6..938822c1d21 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksAdd.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksAdd.java @@ -20,6 +20,7 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -39,7 +40,8 @@ import java.util.List; * ScalarFunction 'weeks_add'. */ public class WeeksAdd extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { // When enable_date_conversion is true, we prefer to V2 signature. // This preference follows original planner. refer to ScalarType.getDefaultDateType() diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksSub.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksSub.java index 14bfc93683b..0be7a20d4c6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksSub.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/WeeksSub.java @@ -20,6 +20,7 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -39,7 +40,8 @@ import java.util.List; * ScalarFunction 'weeks_sub'. */ public class WeeksSub extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { // When enable_date_conversion is true, we prefer to V2 signature. // This preference follows original planner. refer to ScalarType.getDefaultDateType() diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsAdd.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsAdd.java index 36c140ffed6..33c9e1c6dfa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsAdd.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsAdd.java @@ -18,7 +18,9 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -38,14 +40,23 @@ import java.util.List; * ScalarFunction 'days_add'. */ public class YearsAdd extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { - private static final List<FunctionSignature> SIGNATURES = ImmutableList.of( + // When enable_date_conversion is true, we prefer to V2 signature. + // This preference follows original planner. refer to ScalarType.getDefaultDateType() + private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE) + ) : ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) + .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) ); public YearsAdd(Expression arg0, Expression arg1) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsSub.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsSub.java index 30112603314..b70444178df 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsSub.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearsSub.java @@ -18,7 +18,9 @@ package org.apache.doris.nereids.trees.expressions.functions.scalar; import org.apache.doris.catalog.FunctionSignature; +import org.apache.doris.common.Config; import org.apache.doris.nereids.trees.expressions.Expression; +import org.apache.doris.nereids.trees.expressions.functions.ComputeSignatureForDateArithmetic; import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature; import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; @@ -38,14 +40,23 @@ import java.util.List; * ScalarFunction 'days_add'. */ public class YearsSub extends ScalarFunction - implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args { + implements BinaryExpression, ExplicitlyCastableSignature, + ComputeSignatureForDateArithmetic, PropagateNullableOnDateLikeV2Args { - private static final List<FunctionSignature> SIGNATURES = ImmutableList.of( + // When enable_date_conversion is true, we prefer to V2 signature. + // This preference follows original planner. refer to ScalarType.getDefaultDateType() + private static final List<FunctionSignature> SIGNATURES = Config.enable_date_conversion ? ImmutableList.of( FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE) + ) : ImmutableList.of( + FunctionSignature.ret(DateTimeType.INSTANCE).args(DateTimeType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateType.INSTANCE).args(DateType.INSTANCE, IntegerType.INSTANCE), + FunctionSignature.ret(DateTimeV2Type.SYSTEM_DEFAULT) + .args(DateTimeV2Type.SYSTEM_DEFAULT, IntegerType.INSTANCE), + FunctionSignature.ret(DateV2Type.INSTANCE).args(DateV2Type.INSTANCE, IntegerType.INSTANCE) ); public YearsSub(Expression arg0, Expression arg1) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java index 3809f56b272..c48191ffeb3 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/ConstantExpressTest.java @@ -78,11 +78,11 @@ public class ConstantExpressTest { testConstantExpressResult( "select date_add('2018-08-08', 1);", - "'2018-08-09 00:00:00'"); + "'2018-08-09'"); testConstantExpressResult( "select date_add('2018-08-08', -1);", - "'2018-08-07 00:00:00'"); + "'2018-08-07'"); testConstantExpressResult( "select date_sub('2018-08-08 07:16:19',1);", diff --git a/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_fe.out b/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_fe.out index 49913803fa2..9d576b50a74 100644 --- a/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_fe.out +++ b/regression-test/data/nereids_p0/expression/fold_constant/fold_constant_by_fe.out @@ -1,9 +1,9 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- -2021-04-13T00:00 2021-04-11T00:00 2022-04-12T00:00 2020-04-12T00:00 +2021-04-13 2021-04-11 2022-04-12 2020-04-12 -- !sql -- -2021-05-12T00:00 2021-03-12T00:00 2021-04-13T00:00 2021-04-11T00:00 +2021-05-12 2021-03-12 2021-04-13 2021-04-11 -- !sql -- 2021-04-12T01:00 2021-04-11T23:00 2021-04-12T00:01 2021-04-11T23:59 @@ -12,10 +12,10 @@ 2021-04-12T00:00:01 2021-04-11T23:59:59 -- !sql -- -2021-04-22T00:00 2021-04-02T00:00 2031-04-12T00:00 2011-04-12T00:00 +2021-04-22 2021-04-02 2031-04-12 2011-04-12 -- !sql -- -2022-02-12T00:00 2020-06-12T00:00 2021-04-22T00:00 2021-04-02T00:00 +2022-02-12 2020-06-12 2021-04-22 2021-04-02 -- !sql -- 2021-04-12T10:00 2021-04-11T14:00 2021-04-12T00:10 2021-04-11T23:50 @@ -24,10 +24,10 @@ 2021-04-12T00:00:10 2021-04-11T23:59:50 -- !sql -- -2021-05-07T00:00 2021-03-18T00:00 2046-04-12T00:00 1996-04-12T00:00 +2021-05-07 2021-03-18 2046-04-12 1996-04-12 -- !sql -- -2023-05-12T00:00 2019-03-12T00:00 2021-05-07T00:00 2021-03-18T00:00 +2023-05-12 2019-03-12 2021-05-07 2021-03-18 -- !sql -- 2021-04-13T01:00 2021-04-10T23:00 2021-04-12T00:25 2021-04-11T23:35 @@ -36,10 +36,10 @@ 2021-04-12T00:00:25 2021-04-11T23:59:35 -- !sql -- -2021-06-01T00:00 2021-02-21T00:00 2071-04-12T00:00 1971-04-12T00:00 +2021-06-01 2021-02-21 2071-04-12 1971-04-12 -- !sql -- -2025-06-12T00:00 2017-02-12T00:00 2021-06-01T00:00 2021-02-21T00:00 +2025-06-12 2017-02-12 2021-06-01 2021-02-21 -- !sql -- 2021-04-14T02:00 2021-04-09T22:00 2021-04-12T00:50 2021-04-11T23:10 @@ -48,10 +48,10 @@ 2021-04-12T00:00:50 2021-04-11T23:59:10 -- !sql -- -2024-01-31T00:00 2018-06-23T00:00 3045-04-12T00:00 0997-04-12T00:00 +2024-01-31 2018-06-23 3045-04-12 0997-04-12 -- !sql -- -2106-08-12T00:00 1935-12-12T00:00 2024-01-31T00:00 2018-06-23T00:00 +2106-08-12 1935-12-12 2024-01-31 2018-06-23 -- !sql -- 2021-05-24T16:00 2021-02-28T08:00 2021-04-12T17:04 2021-04-11T06:56 @@ -60,10 +60,10 @@ 2021-04-12T00:17:04 2021-04-11T23:42:56 -- !sql -- -1970-01-01T00:00 1969-12-30T00:00 1970-12-31T00:00 1968-12-31T00:00 +1970-01-01 1969-12-30 1970-12-31 1968-12-31 -- !sql -- -1970-01-31T00:00 1969-11-30T00:00 1970-01-01T00:00 1969-12-30T00:00 +1970-01-31 1969-11-30 1970-01-01 1969-12-30 -- !sql -- 1969-12-31T01:00 1969-12-30T23:00 1969-12-31T00:01 1969-12-30T23:59 @@ -72,10 +72,10 @@ 1969-12-31T00:00:01 1969-12-30T23:59:59 -- !sql -- -1970-01-10T00:00 1969-12-21T00:00 1979-12-31T00:00 1959-12-31T00:00 +1970-01-10 1969-12-21 1979-12-31 1959-12-31 -- !sql -- -1970-10-31T00:00 1969-02-28T00:00 1970-01-10T00:00 1969-12-21T00:00 +1970-10-31 1969-02-28 1970-01-10 1969-12-21 -- !sql -- 1969-12-31T10:00 1969-12-30T14:00 1969-12-31T00:10 1969-12-30T23:50 @@ -84,10 +84,10 @@ 1969-12-31T00:00:10 1969-12-30T23:59:50 -- !sql -- -1970-01-25T00:00 1969-12-06T00:00 1994-12-31T00:00 1944-12-31T00:00 +1970-01-25 1969-12-06 1994-12-31 1944-12-31 -- !sql -- -1972-01-31T00:00 1967-11-30T00:00 1970-01-25T00:00 1969-12-06T00:00 +1972-01-31 1967-11-30 1970-01-25 1969-12-06 -- !sql -- 1970-01-01T01:00 1969-12-29T23:00 1969-12-31T00:25 1969-12-30T23:35 @@ -96,10 +96,10 @@ 1969-12-31T00:00:25 1969-12-30T23:59:35 -- !sql -- -1970-02-19T00:00 1969-11-11T00:00 2019-12-31T00:00 1919-12-31T00:00 +1970-02-19 1969-11-11 2019-12-31 1919-12-31 -- !sql -- -1974-02-28T00:00 1965-10-31T00:00 1970-02-19T00:00 1969-11-11T00:00 +1974-02-28 1965-10-31 1970-02-19 1969-11-11 -- !sql -- 1970-01-02T02:00 1969-12-28T22:00 1969-12-31T00:50 1969-12-30T23:10 @@ -108,10 +108,10 @@ 1969-12-31T00:00:50 1969-12-30T23:59:10 -- !sql -- -1972-10-20T00:00 1967-03-13T00:00 2993-12-31T00:00 0945-12-31T00:00 +1972-10-20 1967-03-13 2993-12-31 0945-12-31 -- !sql -- -2055-04-30T00:00 1884-08-31T00:00 1972-10-20T00:00 1967-03-13T00:00 +2055-04-30 1884-08-31 1972-10-20 1967-03-13 -- !sql -- 1970-02-11T16:00 1969-11-18T08:00 1969-12-31T17:04 1969-12-30T06:56 @@ -120,10 +120,10 @@ 1969-12-31T00:17:04 1969-12-30T23:42:56 -- !sql -- -1356-12-13T00:00 1356-12-11T00:00 1357-12-12T00:00 1355-12-12T00:00 +1356-12-13 1356-12-11 1357-12-12 1355-12-12 -- !sql -- -1357-01-12T00:00 1356-11-12T00:00 1356-12-13T00:00 1356-12-11T00:00 +1357-01-12 1356-11-12 1356-12-13 1356-12-11 -- !sql -- 1356-12-12T01:00 1356-12-11T23:00 1356-12-12T00:01 1356-12-11T23:59 @@ -132,10 +132,10 @@ 1356-12-12T00:00:01 1356-12-11T23:59:59 -- !sql -- -1356-12-22T00:00 1356-12-02T00:00 1366-12-12T00:00 1346-12-12T00:00 +1356-12-22 1356-12-02 1366-12-12 1346-12-12 -- !sql -- -1357-10-12T00:00 1356-02-12T00:00 1356-12-22T00:00 1356-12-02T00:00 +1357-10-12 1356-02-12 1356-12-22 1356-12-02 -- !sql -- 1356-12-12T10:00 1356-12-11T14:00 1356-12-12T00:10 1356-12-11T23:50 @@ -144,10 +144,10 @@ 1356-12-12T00:00:10 1356-12-11T23:59:50 -- !sql -- -1357-01-06T00:00 1356-11-17T00:00 1381-12-12T00:00 1331-12-12T00:00 +1357-01-06 1356-11-17 1381-12-12 1331-12-12 -- !sql -- -1359-01-12T00:00 1354-11-12T00:00 1357-01-06T00:00 1356-11-17T00:00 +1359-01-12 1354-11-12 1357-01-06 1356-11-17 -- !sql -- 1356-12-13T01:00 1356-12-10T23:00 1356-12-12T00:25 1356-12-11T23:35 @@ -156,10 +156,10 @@ 1356-12-12T00:00:25 1356-12-11T23:59:35 -- !sql -- -1357-01-31T00:00 1356-10-23T00:00 1406-12-12T00:00 1306-12-12T00:00 +1357-01-31 1356-10-23 1406-12-12 1306-12-12 -- !sql -- -1361-02-12T00:00 1352-10-12T00:00 1357-01-31T00:00 1356-10-23T00:00 +1361-02-12 1352-10-12 1357-01-31 1356-10-23 -- !sql -- 1356-12-14T02:00 1356-12-09T22:00 1356-12-12T00:50 1356-12-11T23:10 @@ -168,10 +168,10 @@ 1356-12-12T00:00:50 1356-12-11T23:59:10 -- !sql -- -1359-10-02T00:00 1354-02-22T00:00 2380-12-12T00:00 0332-12-12T00:00 +1359-10-02 1354-02-22 2380-12-12 0332-12-12 -- !sql -- -1442-04-12T00:00 1271-08-12T00:00 1359-10-02T00:00 1354-02-22T00:00 +1442-04-12 1271-08-12 1359-10-02 1354-02-22 -- !sql -- 1357-01-23T16:00 1356-10-30T08:00 1356-12-12T17:04 1356-12-11T06:56 @@ -180,10 +180,10 @@ 1356-12-12T00:17:04 1356-12-11T23:42:56 -- !sql -- -0001-01-02T00:00 0000-12-31T00:00 0002-01-01T00:00 0000-01-01T00:00 +0001-01-02 0000-12-31 0002-01-01 0000-01-01 -- !sql -- -0001-02-01T00:00 0000-12-01T00:00 0001-01-02T00:00 0000-12-31T00:00 +0001-02-01 0000-12-01 0001-01-02 0000-12-31 -- !sql -- 0001-01-01T01:00 0000-12-31T23:00 0001-01-01T00:01 0000-12-31T23:59 @@ -192,10 +192,10 @@ 0001-01-01T00:00:01 0000-12-31T23:59:59 -- !sql -- -0001-01-11T00:00 0000-12-22T00:00 0011-01-01T00:00 \N +0001-01-11 0000-12-22 0011-01-01 \N -- !sql -- -0001-11-01T00:00 0000-03-01T00:00 0001-01-11T00:00 0000-12-22T00:00 +0001-11-01 0000-03-01 0001-01-11 0000-12-22 -- !sql -- 0001-01-01T10:00 0000-12-31T14:00 0001-01-01T00:10 0000-12-31T23:50 @@ -204,10 +204,10 @@ 0001-01-01T00:00:10 0000-12-31T23:59:50 -- !sql -- -0001-01-26T00:00 0000-12-07T00:00 0026-01-01T00:00 \N +0001-01-26 0000-12-07 0026-01-01 \N -- !sql -- -0003-02-01T00:00 \N 0001-01-26T00:00 0000-12-07T00:00 +0003-02-01 \N 0001-01-26 0000-12-07 -- !sql -- 0001-01-02T01:00 0000-12-30T23:00 0001-01-01T00:25 0000-12-31T23:35 @@ -216,10 +216,10 @@ 0001-01-01T00:00:25 0000-12-31T23:59:35 -- !sql -- -0001-02-20T00:00 0000-11-12T00:00 0051-01-01T00:00 \N +0001-02-20 0000-11-12 0051-01-01 \N -- !sql -- -0005-03-01T00:00 \N 0001-02-20T00:00 0000-11-12T00:00 +0005-03-01 \N 0001-02-20 0000-11-12 -- !sql -- 0001-01-03T02:00 0000-12-29T22:00 0001-01-01T00:50 0000-12-31T23:10 @@ -228,10 +228,10 @@ 0001-01-01T00:00:50 0000-12-31T23:59:10 -- !sql -- -0003-10-22T00:00 \N 1025-01-01T00:00 \N +0003-10-22 \N 1025-01-01 \N -- !sql -- -0086-05-01T00:00 \N 0003-10-22T00:00 \N +0086-05-01 \N 0003-10-22 \N -- !sql -- 0001-02-12T16:00 0000-11-19T08:00 0001-01-01T17:04 0000-12-31T06:56 @@ -240,10 +240,10 @@ 0001-01-01T00:17:04 0000-12-31T23:42:56 -- !sql -- -9999-01-01T00:00 9998-12-30T00:00 9999-12-31T00:00 9997-12-31T00:00 +9999-01-01 9998-12-30 9999-12-31 9997-12-31 -- !sql -- -9999-01-31T00:00 9998-11-30T00:00 9999-01-01T00:00 9998-12-30T00:00 +9999-01-31 9998-11-30 9999-01-01 9998-12-30 -- !sql -- 9998-12-31T01:00 9998-12-30T23:00 9998-12-31T00:01 9998-12-30T23:59 @@ -252,10 +252,10 @@ 9998-12-31T00:00:01 9998-12-30T23:59:59 -- !sql -- -9999-01-10T00:00 9998-12-21T00:00 \N 9988-12-31T00:00 +9999-01-10 9998-12-21 \N 9988-12-31 -- !sql -- -9999-10-31T00:00 9998-02-28T00:00 9999-01-10T00:00 9998-12-21T00:00 +9999-10-31 9998-02-28 9999-01-10 9998-12-21 -- !sql -- 9998-12-31T10:00 9998-12-30T14:00 9998-12-31T00:10 9998-12-30T23:50 @@ -264,10 +264,10 @@ 9998-12-31T00:00:10 9998-12-30T23:59:50 -- !sql -- -9999-01-25T00:00 9998-12-06T00:00 \N 9973-12-31T00:00 +9999-01-25 9998-12-06 \N 9973-12-31 -- !sql -- -\N 9996-11-30T00:00 9999-01-25T00:00 9998-12-06T00:00 +\N 9996-11-30 9999-01-25 9998-12-06 -- !sql -- 9999-01-01T01:00 9998-12-29T23:00 9998-12-31T00:25 9998-12-30T23:35 @@ -276,10 +276,10 @@ 9998-12-31T00:00:25 9998-12-30T23:59:35 -- !sql -- -9999-02-19T00:00 9998-11-11T00:00 \N 9948-12-31T00:00 +9999-02-19 9998-11-11 \N 9948-12-31 -- !sql -- -\N 9994-10-31T00:00 9999-02-19T00:00 9998-11-11T00:00 +\N 9994-10-31 9999-02-19 9998-11-11 -- !sql -- 9999-01-02T02:00 9998-12-28T22:00 9998-12-31T00:50 9998-12-30T23:10 @@ -288,10 +288,10 @@ 9998-12-31T00:00:50 9998-12-30T23:59:10 -- !sql -- -\N 9996-03-12T00:00 \N 8974-12-31T00:00 +\N 9996-03-12 \N 8974-12-31 -- !sql -- -\N 9913-08-31T00:00 \N 9996-03-12T00:00 +\N 9913-08-31 \N 9996-03-12 -- !sql -- 9999-02-11T16:00 9998-11-18T08:00 9998-12-31T17:04 9998-12-30T06:56 @@ -300,10 +300,10 @@ 9998-12-31T00:17:04 9998-12-30T23:42:56 -- !sql -- -2021-04-13T00:00 2021-04-11T00:00 2022-04-12T00:00 2020-04-12T00:00 +2021-04-13 2021-04-11 2022-04-12 2020-04-12 -- !sql -- -2021-05-12T00:00 2021-03-12T00:00 2021-04-13T00:00 2021-04-11T00:00 +2021-05-12 2021-03-12 2021-04-13 2021-04-11 -- !sql -- 2021-04-12T01:00 2021-04-11T23:00 2021-04-12T00:01 2021-04-11T23:59 @@ -312,10 +312,10 @@ 2021-04-12T00:00:01 2021-04-11T23:59:59 -- !sql -- -2021-04-22T00:00 2021-04-02T00:00 2031-04-12T00:00 2011-04-12T00:00 +2021-04-22 2021-04-02 2031-04-12 2011-04-12 -- !sql -- -2022-02-12T00:00 2020-06-12T00:00 2021-04-22T00:00 2021-04-02T00:00 +2022-02-12 2020-06-12 2021-04-22 2021-04-02 -- !sql -- 2021-04-12T10:00 2021-04-11T14:00 2021-04-12T00:10 2021-04-11T23:50 @@ -324,10 +324,10 @@ 2021-04-12T00:00:10 2021-04-11T23:59:50 -- !sql -- -2021-05-07T00:00 2021-03-18T00:00 2046-04-12T00:00 1996-04-12T00:00 +2021-05-07 2021-03-18 2046-04-12 1996-04-12 -- !sql -- -2023-05-12T00:00 2019-03-12T00:00 2021-05-07T00:00 2021-03-18T00:00 +2023-05-12 2019-03-12 2021-05-07 2021-03-18 -- !sql -- 2021-04-13T01:00 2021-04-10T23:00 2021-04-12T00:25 2021-04-11T23:35 @@ -336,10 +336,10 @@ 2021-04-12T00:00:25 2021-04-11T23:59:35 -- !sql -- -2021-06-01T00:00 2021-02-21T00:00 2071-04-12T00:00 1971-04-12T00:00 +2021-06-01 2021-02-21 2071-04-12 1971-04-12 -- !sql -- -2025-06-12T00:00 2017-02-12T00:00 2021-06-01T00:00 2021-02-21T00:00 +2025-06-12 2017-02-12 2021-06-01 2021-02-21 -- !sql -- 2021-04-14T02:00 2021-04-09T22:00 2021-04-12T00:50 2021-04-11T23:10 @@ -348,10 +348,10 @@ 2021-04-12T00:00:50 2021-04-11T23:59:10 -- !sql -- -2024-01-31T00:00 2018-06-23T00:00 3045-04-12T00:00 0997-04-12T00:00 +2024-01-31 2018-06-23 3045-04-12 0997-04-12 -- !sql -- -2106-08-12T00:00 1935-12-12T00:00 2024-01-31T00:00 2018-06-23T00:00 +2106-08-12 1935-12-12 2024-01-31 2018-06-23 -- !sql -- 2021-05-24T16:00 2021-02-28T08:00 2021-04-12T17:04 2021-04-11T06:56 @@ -360,10 +360,10 @@ 2021-04-12T00:17:04 2021-04-11T23:42:56 -- !sql -- -1970-01-01T00:00 1969-12-30T00:00 1970-12-31T00:00 1968-12-31T00:00 +1970-01-01 1969-12-30 1970-12-31 1968-12-31 -- !sql -- -1970-01-31T00:00 1969-11-30T00:00 1970-01-01T00:00 1969-12-30T00:00 +1970-01-31 1969-11-30 1970-01-01 1969-12-30 -- !sql -- 1969-12-31T01:00 1969-12-30T23:00 1969-12-31T00:01 1969-12-30T23:59 @@ -372,10 +372,10 @@ 1969-12-31T00:00:01 1969-12-30T23:59:59 -- !sql -- -1970-01-10T00:00 1969-12-21T00:00 1979-12-31T00:00 1959-12-31T00:00 +1970-01-10 1969-12-21 1979-12-31 1959-12-31 -- !sql -- -1970-10-31T00:00 1969-02-28T00:00 1970-01-10T00:00 1969-12-21T00:00 +1970-10-31 1969-02-28 1970-01-10 1969-12-21 -- !sql -- 1969-12-31T10:00 1969-12-30T14:00 1969-12-31T00:10 1969-12-30T23:50 @@ -384,10 +384,10 @@ 1969-12-31T00:00:10 1969-12-30T23:59:50 -- !sql -- -1970-01-25T00:00 1969-12-06T00:00 1994-12-31T00:00 1944-12-31T00:00 +1970-01-25 1969-12-06 1994-12-31 1944-12-31 -- !sql -- -1972-01-31T00:00 1967-11-30T00:00 1970-01-25T00:00 1969-12-06T00:00 +1972-01-31 1967-11-30 1970-01-25 1969-12-06 -- !sql -- 1970-01-01T01:00 1969-12-29T23:00 1969-12-31T00:25 1969-12-30T23:35 @@ -396,10 +396,10 @@ 1969-12-31T00:00:25 1969-12-30T23:59:35 -- !sql -- -1970-02-19T00:00 1969-11-11T00:00 2019-12-31T00:00 1919-12-31T00:00 +1970-02-19 1969-11-11 2019-12-31 1919-12-31 -- !sql -- -1974-02-28T00:00 1965-10-31T00:00 1970-02-19T00:00 1969-11-11T00:00 +1974-02-28 1965-10-31 1970-02-19 1969-11-11 -- !sql -- 1970-01-02T02:00 1969-12-28T22:00 1969-12-31T00:50 1969-12-30T23:10 @@ -408,10 +408,10 @@ 1969-12-31T00:00:50 1969-12-30T23:59:10 -- !sql -- -1972-10-20T00:00 1967-03-13T00:00 2993-12-31T00:00 0945-12-31T00:00 +1972-10-20 1967-03-13 2993-12-31 0945-12-31 -- !sql -- -2055-04-30T00:00 1884-08-31T00:00 1972-10-20T00:00 1967-03-13T00:00 +2055-04-30 1884-08-31 1972-10-20 1967-03-13 -- !sql -- 1970-02-11T16:00 1969-11-18T08:00 1969-12-31T17:04 1969-12-30T06:56 @@ -420,10 +420,10 @@ 1969-12-31T00:17:04 1969-12-30T23:42:56 -- !sql -- -1356-12-13T00:00 1356-12-11T00:00 1357-12-12T00:00 1355-12-12T00:00 +1356-12-13 1356-12-11 1357-12-12 1355-12-12 -- !sql -- -1357-01-12T00:00 1356-11-12T00:00 1356-12-13T00:00 1356-12-11T00:00 +1357-01-12 1356-11-12 1356-12-13 1356-12-11 -- !sql -- 1356-12-12T01:00 1356-12-11T23:00 1356-12-12T00:01 1356-12-11T23:59 @@ -432,10 +432,10 @@ 1356-12-12T00:00:01 1356-12-11T23:59:59 -- !sql -- -1356-12-22T00:00 1356-12-02T00:00 1366-12-12T00:00 1346-12-12T00:00 +1356-12-22 1356-12-02 1366-12-12 1346-12-12 -- !sql -- -1357-10-12T00:00 1356-02-12T00:00 1356-12-22T00:00 1356-12-02T00:00 +1357-10-12 1356-02-12 1356-12-22 1356-12-02 -- !sql -- 1356-12-12T10:00 1356-12-11T14:00 1356-12-12T00:10 1356-12-11T23:50 @@ -444,10 +444,10 @@ 1356-12-12T00:00:10 1356-12-11T23:59:50 -- !sql -- -1357-01-06T00:00 1356-11-17T00:00 1381-12-12T00:00 1331-12-12T00:00 +1357-01-06 1356-11-17 1381-12-12 1331-12-12 -- !sql -- -1359-01-12T00:00 1354-11-12T00:00 1357-01-06T00:00 1356-11-17T00:00 +1359-01-12 1354-11-12 1357-01-06 1356-11-17 -- !sql -- 1356-12-13T01:00 1356-12-10T23:00 1356-12-12T00:25 1356-12-11T23:35 @@ -456,10 +456,10 @@ 1356-12-12T00:00:25 1356-12-11T23:59:35 -- !sql -- -1357-01-31T00:00 1356-10-23T00:00 1406-12-12T00:00 1306-12-12T00:00 +1357-01-31 1356-10-23 1406-12-12 1306-12-12 -- !sql -- -1361-02-12T00:00 1352-10-12T00:00 1357-01-31T00:00 1356-10-23T00:00 +1361-02-12 1352-10-12 1357-01-31 1356-10-23 -- !sql -- 1356-12-14T02:00 1356-12-09T22:00 1356-12-12T00:50 1356-12-11T23:10 @@ -468,10 +468,10 @@ 1356-12-12T00:00:50 1356-12-11T23:59:10 -- !sql -- -1359-10-02T00:00 1354-02-22T00:00 2380-12-12T00:00 0332-12-12T00:00 +1359-10-02 1354-02-22 2380-12-12 0332-12-12 -- !sql -- -1442-04-12T00:00 1271-08-12T00:00 1359-10-02T00:00 1354-02-22T00:00 +1442-04-12 1271-08-12 1359-10-02 1354-02-22 -- !sql -- 1357-01-23T16:00 1356-10-30T08:00 1356-12-12T17:04 1356-12-11T06:56 @@ -480,10 +480,10 @@ 1356-12-12T00:17:04 1356-12-11T23:42:56 -- !sql -- -0001-01-02T00:00 0000-12-31T00:00 0002-01-01T00:00 0000-01-01T00:00 +0001-01-02 0000-12-31 0002-01-01 0000-01-01 -- !sql -- -0001-02-01T00:00 0000-12-01T00:00 0001-01-02T00:00 0000-12-31T00:00 +0001-02-01 0000-12-01 0001-01-02 0000-12-31 -- !sql -- 0001-01-01T01:00 0000-12-31T23:00 0001-01-01T00:01 0000-12-31T23:59 @@ -492,10 +492,10 @@ 0001-01-01T00:00:01 0000-12-31T23:59:59 -- !sql -- -0001-01-11T00:00 0000-12-22T00:00 0011-01-01T00:00 \N +0001-01-11 0000-12-22 0011-01-01 \N -- !sql -- -0001-11-01T00:00 0000-03-01T00:00 0001-01-11T00:00 0000-12-22T00:00 +0001-11-01 0000-03-01 0001-01-11 0000-12-22 -- !sql -- 0001-01-01T10:00 0000-12-31T14:00 0001-01-01T00:10 0000-12-31T23:50 @@ -504,10 +504,10 @@ 0001-01-01T00:00:10 0000-12-31T23:59:50 -- !sql -- -0001-01-26T00:00 0000-12-07T00:00 0026-01-01T00:00 \N +0001-01-26 0000-12-07 0026-01-01 \N -- !sql -- -0003-02-01T00:00 \N 0001-01-26T00:00 0000-12-07T00:00 +0003-02-01 \N 0001-01-26 0000-12-07 -- !sql -- 0001-01-02T01:00 0000-12-30T23:00 0001-01-01T00:25 0000-12-31T23:35 @@ -516,10 +516,10 @@ 0001-01-01T00:00:25 0000-12-31T23:59:35 -- !sql -- -0001-02-20T00:00 0000-11-12T00:00 0051-01-01T00:00 \N +0001-02-20 0000-11-12 0051-01-01 \N -- !sql -- -0005-03-01T00:00 \N 0001-02-20T00:00 0000-11-12T00:00 +0005-03-01 \N 0001-02-20 0000-11-12 -- !sql -- 0001-01-03T02:00 0000-12-29T22:00 0001-01-01T00:50 0000-12-31T23:10 @@ -528,10 +528,10 @@ 0001-01-01T00:00:50 0000-12-31T23:59:10 -- !sql -- -0003-10-22T00:00 \N 1025-01-01T00:00 \N +0003-10-22 \N 1025-01-01 \N -- !sql -- -0086-05-01T00:00 \N 0003-10-22T00:00 \N +0086-05-01 \N 0003-10-22 \N -- !sql -- 0001-02-12T16:00 0000-11-19T08:00 0001-01-01T17:04 0000-12-31T06:56 @@ -540,10 +540,10 @@ 0001-01-01T00:17:04 0000-12-31T23:42:56 -- !sql -- -9999-01-01T00:00 9998-12-30T00:00 9999-12-31T00:00 9997-12-31T00:00 +9999-01-01 9998-12-30 9999-12-31 9997-12-31 -- !sql -- -9999-01-31T00:00 9998-11-30T00:00 9999-01-01T00:00 9998-12-30T00:00 +9999-01-31 9998-11-30 9999-01-01 9998-12-30 -- !sql -- 9998-12-31T01:00 9998-12-30T23:00 9998-12-31T00:01 9998-12-30T23:59 @@ -552,10 +552,10 @@ 9998-12-31T00:00:01 9998-12-30T23:59:59 -- !sql -- -9999-01-10T00:00 9998-12-21T00:00 \N 9988-12-31T00:00 +9999-01-10 9998-12-21 \N 9988-12-31 -- !sql -- -9999-10-31T00:00 9998-02-28T00:00 9999-01-10T00:00 9998-12-21T00:00 +9999-10-31 9998-02-28 9999-01-10 9998-12-21 -- !sql -- 9998-12-31T10:00 9998-12-30T14:00 9998-12-31T00:10 9998-12-30T23:50 @@ -564,10 +564,10 @@ 9998-12-31T00:00:10 9998-12-30T23:59:50 -- !sql -- -9999-01-25T00:00 9998-12-06T00:00 \N 9973-12-31T00:00 +9999-01-25 9998-12-06 \N 9973-12-31 -- !sql -- -\N 9996-11-30T00:00 9999-01-25T00:00 9998-12-06T00:00 +\N 9996-11-30 9999-01-25 9998-12-06 -- !sql -- 9999-01-01T01:00 9998-12-29T23:00 9998-12-31T00:25 9998-12-30T23:35 @@ -576,10 +576,10 @@ 9998-12-31T00:00:25 9998-12-30T23:59:35 -- !sql -- -9999-02-19T00:00 9998-11-11T00:00 \N 9948-12-31T00:00 +9999-02-19 9998-11-11 \N 9948-12-31 -- !sql -- -\N 9994-10-31T00:00 9999-02-19T00:00 9998-11-11T00:00 +\N 9994-10-31 9999-02-19 9998-11-11 -- !sql -- 9999-01-02T02:00 9998-12-28T22:00 9998-12-31T00:50 9998-12-30T23:10 @@ -588,10 +588,10 @@ 9998-12-31T00:00:50 9998-12-30T23:59:10 -- !sql -- -\N 9996-03-12T00:00 \N 8974-12-31T00:00 +\N 9996-03-12 \N 8974-12-31 -- !sql -- -\N 9913-08-31T00:00 \N 9996-03-12T00:00 +\N 9913-08-31 \N 9996-03-12 -- !sql -- 9999-02-11T16:00 9998-11-18T08:00 9998-12-31T17:04 9998-12-30T06:56 diff --git a/regression-test/data/nereids_syntax_p0/test_date_add.out b/regression-test/data/nereids_syntax_p0/test_date_add.out index 5189522ae5c..c1cc88ef036 100644 --- a/regression-test/data/nereids_syntax_p0/test_date_add.out +++ b/regression-test/data/nereids_syntax_p0/test_date_add.out @@ -9,34 +9,34 @@ 2020-01-01T00:00:02 -- !select -- -2020-01-03T00:00 +2020-01-03 -- !select -- -2020-01-03T00:00 +2020-01-03 -- !select -- -2020-01-03T00:00 +2020-01-03 -- !select -- -2019-12-28T00:00 +2019-12-28 -- !select -- -2022-01-01T00:00 +2022-01-01 -- !select -- -2016-01-01T00:00 +2016-01-01 -- !select -- -2020-03-01T00:00 +2020-03-01 -- !select -- -2019-09-01T00:00 +2019-09-01 -- !select -- -2020-01-15T00:00 +2020-01-15 -- !select -- -2019-12-04T00:00 +2019-12-04 -- !select -- 2020-01-01T02:00 @@ -57,16 +57,16 @@ 2019-12-31T23:59:56 -- !sql -- -2004-02-01T00:00 +2004-02-01 -- !sql -- -2003-03-01T00:00 +2003-03-01 -- !sql -- -2003-02-08T00:00 +2003-02-08 -- !sql -- -2003-02-02T00:00 +2003-02-02 -- !sql -- 2003-02-01T01:00 diff --git a/regression-test/data/nereids_syntax_p0/test_date_sub.out b/regression-test/data/nereids_syntax_p0/test_date_sub.out index 2b4d86dad8a..b9df7eaa28c 100644 --- a/regression-test/data/nereids_syntax_p0/test_date_sub.out +++ b/regression-test/data/nereids_syntax_p0/test_date_sub.out @@ -12,7 +12,7 @@ 2018-01-01T00:00 -- !select -- -2018-01-01T00:00 +2018-01-01 -- !select -- 2019-12-31T23:58 @@ -30,7 +30,7 @@ 2019-12-31T23:58 -- !select -- -2019-12-30T00:00 +2019-12-30 -- !select -- 2019-12-31T22:00 @@ -42,34 +42,34 @@ 2019-12-31T23:59:58 -- !select -- -2019-12-30T00:00 +2019-12-30 -- !select -- -2019-12-30T00:00 +2019-12-30 -- !select -- -2019-12-30T00:00 +2019-12-30 -- !select -- -2020-01-05T00:00 +2020-01-05 -- !select -- -2018-01-01T00:00 +2018-01-01 -- !select -- -2024-01-01T00:00 +2024-01-01 -- !select -- -2019-11-01T00:00 +2019-11-01 -- !select -- -2020-05-01T00:00 +2020-05-01 -- !select -- -2019-12-18T00:00 +2019-12-18 -- !select -- -2020-01-29T00:00 +2020-01-29 -- !select -- 2019-12-31T22:00 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org