You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/16 13:52:45 UTC
[doris] branch master updated: [Bug](datev2) Fix compatible problems caused by datev2 (#15131)
This is an automated email from the ASF dual-hosted git repository.
morningman 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 67b9d469c1 [Bug](datev2) Fix compatible problems caused by datev2 (#15131)
67b9d469c1 is described below
commit 67b9d469c148b88f6ae2c196e2cbba33c5a91af9
Author: Gabriel <ga...@gmail.com>
AuthorDate: Fri Dec 16 21:52:39 2022 +0800
[Bug](datev2) Fix compatible problems caused by datev2 (#15131)
This bug is introduced by #15094
---
.../org/apache/doris/analysis/DateLiteral.java | 37 ++++++++++++++++++++++
.../org/apache/doris/catalog/PartitionKey.java | 10 ++++++
2 files changed, 47 insertions(+)
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 2a6efebd40..2377351822 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
@@ -769,6 +769,33 @@ public class DateLiteral extends LiteralExpr {
}
}
+ @Override
+ public void checkValueValid() throws AnalysisException {
+ if (year < 0 || year > 9999) {
+ throw new AnalysisException("DateLiteral has invalid year value: " + year);
+ }
+ if (month < 1 || month > 12) {
+ throw new AnalysisException("DateLiteral has invalid month value: " + month);
+ }
+ if (day < 1 || day > 31) {
+ throw new AnalysisException("DateLiteral has invalid day value: " + day);
+ }
+ if (type.isDatetimeV2() || type.isDatetime()) {
+ if (hour < 0 || hour > 24) {
+ throw new AnalysisException("DateLiteral has invalid hour value: " + hour);
+ }
+ if (minute < 0 || minute > 60) {
+ throw new AnalysisException("DateLiteral has invalid minute value: " + minute);
+ }
+ if (second < 0 || second > 60) {
+ throw new AnalysisException("DateLiteral has invalid second value: " + second);
+ }
+ if (type.isDatetimeV2() && (microsecond < 0 || microsecond > 999999)) {
+ throw new AnalysisException("DateLiteral has invalid microsecond value: " + microsecond);
+ }
+ }
+ }
+
public static DateLiteral read(DataInput in) throws IOException {
DateLiteral literal = new DateLiteral();
literal.readFields(in);
@@ -1621,4 +1648,14 @@ public class DateLiteral extends LiteralExpr {
throw new AnalysisException("Datetime value is out of range: " + dateStr);
}
}
+
+ public void setMinValue() {
+ year = 0;
+ month = 1;
+ day = 1;
+ hour = 0;
+ minute = 0;
+ second = 0;
+ microsecond = 0;
+ }
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
index 68b49c2974..6f26d4ff3a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/PartitionKey.java
@@ -338,6 +338,16 @@ public class PartitionKey implements Comparable<PartitionKey>, Writable {
if (type != PrimitiveType.DATETIMEV2) {
literal.setType(Type.fromPrimitiveType(type));
}
+ if (type.isDateV2Type()) {
+ try {
+ literal.checkValueValid();
+ } catch (AnalysisException e) {
+ LOG.warn("Value {} for partition key [type = {}] is invalid! This is a bug exists in Doris "
+ + "1.2.0 and fixed since Doris 1.2.1. You should create this table again using Doris "
+ + "1.2.1+ .", literal.getStringValue(), type);
+ ((DateLiteral) literal).setMinValue();
+ }
+ }
keys.add(literal);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org