This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 67ba1e5d3f2 [opt](Nereids) date literal support basic format with timezone (#33662) 67ba1e5d3f2 is described below commit 67ba1e5d3f2eb539806edb1ff9dc281f7b7f0f85 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Tue Apr 16 14:07:17 2024 +0800 [opt](Nereids) date literal support basic format with timezone (#33662) --- .../trees/expressions/literal/DateTimeLiteral.java | 4 ++++ .../doris/nereids/util/DateTimeFormatterUtils.java | 2 ++ .../trees/expressions/literal/DateTimeLiteralTest.java | 16 +++------------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteral.java index 0a0f095fe5f..1fc446da356 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteral.java @@ -103,6 +103,10 @@ public class DateTimeLiteral extends DateLiteral { if (!s.contains("-") && !s.contains(":")) { return 0; } + // means basic format with timezone + if (s.indexOf("-") == s.lastIndexOf("-") && s.indexOf(":") == s.lastIndexOf(":")) { + return 0; + } s = normalize(s); if (s.length() <= 19 || s.charAt(19) != '.') { return 0; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java index 6b52fb24a93..f556974d8e6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java @@ -78,11 +78,13 @@ public class DateTimeFormatterUtils { .append(BASIC_DATE_FORMATTER) .appendLiteral('T') .append(BASIC_TIME_FORMATTER) + .appendOptional(ZONE_FORMATTER) .toFormatter().withResolverStyle(ResolverStyle.STRICT); // Date without delimiter public static final DateTimeFormatter BASIC_FORMATTER_WITHOUT_T = new DateTimeFormatterBuilder() .append(BASIC_DATE_FORMATTER) .appendOptional(BASIC_TIME_FORMATTER) + .appendOptional(ZONE_FORMATTER) .toFormatter().withResolverStyle(ResolverStyle.STRICT); // Datetime diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java index ea930e2b73d..184cf5dbf63 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateTimeLiteralTest.java @@ -167,18 +167,7 @@ class DateTimeLiteralTest { } @Test - @Disabled void testOffset() { - new DateTimeV2Literal("2022-08-01 01:01:01+01:01:01"); - new DateTimeV2Literal("2022-08-01 01:01:01+01:01"); - new DateTimeV2Literal("2022-08-01 01:01:01+01"); - new DateTimeV2Literal("2022-08-01 01:01:01+01:1:01"); - new DateTimeV2Literal("2022-08-01 01:01:01+01:1"); - new DateTimeV2Literal("2022-08-01 01:01:01+01:01:1"); - new DateTimeV2Literal("2022-08-01 01:01:01+1:1:1"); - new DateTimeV2Literal("2022-08-01 01:01:01+1:1"); - new DateTimeV2Literal("2022-08-01 01:01:01+1"); - new DateTimeV2Literal("2022-05-01 01:02:55+02:30"); new DateTimeV2Literal("2022-05-01 01:02:55.123-02:30"); new DateTimeV2Literal("2022-06-01T01:02:55+04:30"); @@ -188,8 +177,9 @@ class DateTimeLiteralTest { new DateTimeV2Literal("2022-05-01 01:02:55.123-02:30"); new DateTimeV2Literal("2022-06-01T01:02:55+04:30"); new DateTimeV2Literal("2022-06-01 01:02:55.123-07:30"); - // new DateTimeV2Literal("20220701010255+07:00"); - // new DateTimeV2Literal("20220701010255-05:00"); + + new DateTimeV2Literal("20220701010255+07:00"); + new DateTimeV2Literal("20220701010255-05:00"); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org