Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,6 +36,7 @@
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.util.Set;
import java.util.function.UnaryOperator;

/**
* Date literal in Nereids.
Expand DownExpand Up@@ -100,7 +101,7 @@ public DateLiteral(DateLiteral other, DataType type) {

// 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) {
Expand DownExpand Up@@ -265,6 +266,8 @@ protected static TemporalAccessor parse(String s) {
try {
TemporalAccessor dateTime;

// remove suffix ' '
s = s.trim();
// parse condition without '-' and ':'
boolean containsPunctuation = false;
for (int i = 0; i < s.length(); i++) {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -214,4 +214,10 @@ void testPoint() {
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 ");
}
}