This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4eb5e14029edf89e8916c4dc7d7f791daaff3444 Author: Gabriel <gabrielleeb...@gmail.com> AuthorDate: Thu Dec 15 09:54:18 2022 +0800 [Bug](datetimev2) Fix wrong result after insertion (#15052) --- .../java/org/apache/doris/analysis/DateLiteral.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java index 8c2fc20303..b73cc7cd24 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java @@ -69,9 +69,9 @@ public class DateLiteral extends LiteralExpr { private static final DateLiteral MAX_DATETIME = new DateLiteral(9999, 12, 31, 23, 59, 59); private static final DateLiteral MIN_DATETIMEV2 - = new DateLiteral(0000, 1, 1, 0, 0, 0, 0); + = new DateLiteral(0000, 1, 1, 0, 0, 0, 0, Type.DATETIMEV2); private static final DateLiteral MAX_DATETIMEV2 - = new DateLiteral(9999, 12, 31, 23, 59, 59, 999999L); + = new DateLiteral(9999, 12, 31, 23, 59, 59, 999999L, Type.DATETIMEV2); private static final int DATEKEY_LENGTH = 8; private static final int DATETIMEKEY_LENGTH = 14; private static final int MAX_MICROSECOND = 999999; @@ -284,7 +284,8 @@ public class DateLiteral extends LiteralExpr { this.type = ScalarType.getDefaultDateType(Type.DATETIME); } - public DateLiteral(long year, long month, long day, long hour, long minute, long second, long microsecond) { + public DateLiteral(long year, long month, long day, long hour, long minute, long second, long microsecond, + Type type) { this.hour = hour; this.minute = minute; this.second = second; @@ -292,7 +293,8 @@ public class DateLiteral extends LiteralExpr { this.month = month; this.day = day; this.microsecond = microsecond; - this.type = Type.DATETIMEV2; + Preconditions.checkArgument(type.isDatetimeV2()); + this.type = type; } public DateLiteral(long year, long month, long day, long hour, long minute, long second, Type type) { @@ -486,7 +488,7 @@ public class DateLiteral extends LiteralExpr { return (year << 9) | (month << 5) | day; } else if (type.equals(Type.DATETIMEV2)) { return (year << 50) | (month << 46) | (day << 41) | (hour << 36) - | (minute << 30) | (second << 24) | microsecond; + | (minute << 30) | (second << 24) | microsecond; } else { Preconditions.checkState(false, "invalid date type: " + type); return -1L; @@ -638,8 +640,8 @@ public class DateLiteral extends LiteralExpr { return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.second, targetType); } else if (targetType.isDatetimeV2()) { - return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.microsecond, - targetType); + return new DateLiteral(this.year, this.month, this.day, this.hour, this.minute, this.second, + this.microsecond, targetType); } else { throw new AnalysisException("Error date literal type : " + type); } @@ -672,7 +674,7 @@ public class DateLiteral extends LiteralExpr { private long makePackedDatetimeV2() { return (year << 50) | (month << 46) | (day << 41) | (hour << 36) - | (minute << 30) | (second << 24) | microsecond; + | (minute << 30) | (second << 24) | microsecond; } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org