Skip to content

Commit

Permalink
fix p0 and feut
Browse files Browse the repository at this point in the history
  • Loading branch information
LiBinfeng-01 committed Dec 26, 2024
1 parent 478f865 commit 32648e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ private static Expression processDateLikeTypeCoercion(ComparisonPredicate cp, Ex
} else if (cp instanceof NullSafeEqual) {
return BooleanLiteral.FALSE;
} else if (cp instanceof GreaterThanEqual || cp instanceof LessThan) {
if (DateLiteral.isDateOutOfRange(((DateV2Literal) right).toJavaDateType().plusDays(1))) {
return BooleanLiteral.FALSE;
}
right = ((DateV2Literal) right).plusDays(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,28 +211,28 @@ static Result<String, AnalysisException> normalize(String s) {
final String currentString = s;
return Result.err(
() -> new AnalysisException("date/datetime literal [" + currentString + "] is invalid")
);
}
i = j;
partNumber += 1;
} else if (isPunctuation(c) || c == ' ' || c == 'T') {
i += 1;
if (partNumber < 3 && isPunctuation(c)) {
sb.append('-');
} else if (partNumber == 3) {
while (i < s.length() && (isPunctuation(s.charAt(i)) || s.charAt(i) == ' ' || s.charAt(i) == 'T')) {
i += 1;
);
}
// avoid add blank before zone-id, for example 2008-08-08 +08:00
// should be normalized to 2008-08-08+08:00
if (i >= s.length() || Character.isDigit(s.charAt(i))) {
sb.append(' ');
}
} else if (partNumber > 3 && isPunctuation(c)) {
sb.append(':');
} else {
final String currentString = s;
return Result.err(
i = j;
partNumber += 1;
} else if (isPunctuation(c) || c == ' ' || c == 'T') {
i += 1;
if (partNumber < 3 && isPunctuation(c)) {
sb.append('-');
} else if (partNumber == 3) {
while (i < s.length() && (isPunctuation(s.charAt(i)) || s.charAt(i) == ' ' || s.charAt(i) == 'T')) {
i += 1;
}
// avoid add blank before zone-id, for example 2008-08-08 +08:00
// should be normalized to 2008-08-08+08:00
if (i >= s.length() || Character.isDigit(s.charAt(i))) {
sb.append(' ');
}
} else if (partNumber > 3 && isPunctuation(c)) {
sb.append(':');
} else {
final String currentString = s;
return Result.err(
() -> new AnalysisException("date/datetime literal [" + currentString + "] is invalid")
);
}
Expand Down Expand Up @@ -372,7 +372,7 @@ protected static boolean checkDate(long year, long month, long day) {
return false;
}

protected static boolean isDateOutOfRange(LocalDateTime dateTime) {
public static boolean isDateOutOfRange(LocalDateTime dateTime) {
return dateTime == null || dateTime.isBefore(START_OF_A_DAY) || dateTime.isAfter(END_OF_A_DAY);
}

Expand Down

0 comments on commit 32648e5

Please sign in to comment.