You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/01/31 15:54:21 UTC
(doris) 09/37: [enhance](Nereids): support DateLiteral with suffix space (#30583)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 2646dc279e6b8c587eb36b538c01287057b599db
Author: jakevin <ja...@gmail.com>
AuthorDate: Tue Jan 30 23:23:23 2024 +0800
[enhance](Nereids): support DateLiteral with suffix space (#30583)
---
.../apache/doris/nereids/trees/expressions/literal/DateLiteral.java | 5 ++++-
.../doris/nereids/trees/expressions/literal/DateLiteralTest.java | 6 ++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java
index f2a136ae771..955522c9797 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteral.java
@@ -36,6 +36,7 @@ import java.time.Year;
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.Set;
+import java.util.function.UnaryOperator;
/**
* Date literal in Nereids.
@@ -100,7 +101,7 @@ public class DateLiteral extends Literal {
// normalize yymmdd -> yyyymmdd
static String normalizeBasic(String s) {
- java.util.function.UnaryOperator<String> normalizeTwoDigit = (input) -> {
+ UnaryOperator<String> normalizeTwoDigit = (input) -> {
String yy = input.substring(0, 2);
int year = Integer.parseInt(yy);
if (year >= 0 && year <= 69) {
@@ -265,6 +266,8 @@ public class DateLiteral extends Literal {
try {
TemporalAccessor dateTime;
+ // remove suffix ' '
+ s = s.trim();
// parse condition without '-' and ':'
boolean containsPunctuation = false;
for (int i = 0; i < s.length(); i++) {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteralTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteralTest.java
index a87a177a1b3..4212d892760 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteralTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/literal/DateLiteralTest.java
@@ -214,4 +214,10 @@ class DateLiteralTest {
new DateTimeV2Literal("2020.02.01 00.00.00.000001");
Assertions.assertThrows(AnalysisException.class, () -> new DateTimeV2Literal("2020.02.01 00.00.00.0000001"));
}
+
+ @Test
+ void testSuffixSpace() {
+ new DateLiteral("2016-07-02 ");
+ new DateLiteral("2016-07-02 00:00:00 ");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org