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 c2cf3a447e5c44e2efc44713ef841337c6c3c80a Author: catpineapple <[email protected]> AuthorDate: Wed Feb 22 19:38:42 2023 +0800 [fix](planner)fix multi partition support datetime column #16759 --- .../apache/doris/analysis/MultiPartitionDesc.java | 28 +++++++++------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java index f3a04cbd6c..803123fcb6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java @@ -34,7 +34,6 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoField; import java.time.temporal.WeekFields; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -131,7 +130,9 @@ public class MultiPartitionDesc implements AllPartitionDesc { } WeekFields weekFields = WeekFields.of(DayOfWeek.of(startDayOfWeek), 1); while (startTime.isBefore(this.endTime)) { - PartitionValue lowerPartitionValue = new PartitionValue(startTime.format(dateTypeFormat())); + PartitionValue lowerPartitionValue = new PartitionValue( + startTime.format(dateTypeFormat(partitionKeyDesc.getLowerValues().get(0).getStringValue())) + ); switch (this.timeUnitType) { case HOUR: partitionName = partitionPrefix + startTime.format(DateTimeFormatter.ofPattern(HOURS_FORMAT)); @@ -167,7 +168,9 @@ public class MultiPartitionDesc implements AllPartitionDesc { if (this.timeUnitType != TimestampArithmeticExpr.TimeUnit.DAY && startTime.isAfter(this.endTime)) { startTime = this.endTime; } - PartitionValue upperPartitionValue = new PartitionValue(startTime.format(dateTypeFormat())); + PartitionValue upperPartitionValue = new PartitionValue( + startTime.format(dateTypeFormat(partitionKeyDesc.getUpperValues().get(0).getStringValue())) + ); PartitionKeyDesc partitionKeyDesc = PartitionKeyDesc.createFixed( Lists.newArrayList(lowerPartitionValue), Lists.newArrayList(upperPartitionValue) @@ -295,21 +298,12 @@ public class MultiPartitionDesc implements AllPartitionDesc { return res; } - private DateTimeFormatter dateTypeFormat() { - return DateTimeFormatter.ofPattern(this.timeUnitType.equals(TimeUnit.HOUR) ? DATETIME_FORMAT : DATE_FORMAT); - } - - - private List<AllPartitionDesc> aaa(int ii) throws AnalysisException { - List<AllPartitionDesc> res = new ArrayList<>(); - for (int i = 0; i < ii; i++) { - if (ii % 2 == 1) { - res.add(new MultiPartitionDesc(null, null)); - } else { - res.add(new SinglePartitionDesc(true, "-", null, null)); - } + private DateTimeFormatter dateTypeFormat(String dateTimeStr) { + String s = DATE_FORMAT; + if (this.timeUnitType.equals(TimeUnit.HOUR) || dateTimeStr.length() == 19) { + s = DATETIME_FORMAT; } - return res; + return DateTimeFormatter.ofPattern(s); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
