catpineapple commented on code in PR #13772:
URL: https://github.com/apache/doris/pull/13772#discussion_r1014970740


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/MultiPartitionDesc.java:
##########
@@ -0,0 +1,316 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.analysis.TimestampArithmeticExpr.TimeUnit;
+import org.apache.doris.catalog.DynamicPartitionProperty;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.util.DynamicPartitionUtil;
+import org.apache.doris.planner.DateTools;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+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;
+
+// to describe the key list partition's information in create table stmt
+public class MultiPartitionDesc implements AllPartitionDesc {
+    public static final String HOURS_FORMAT = "yyyyMMddHH";
+    public static final String HOUR_FORMAT = "yyyy-MM-dd HH";
+    public static final String DATES_FORMAT = "yyyyMMdd";
+    public static final String DATE_FORMAT = "yyyy-MM-dd";
+    public static final String MONTHS_FORMAT = "yyyyMM";
+    public static final String MONTH_FORMAT = "yyyy-MM";
+    public static final String YEAR_FORMAT = "yyyy";
+    public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+
+
+    private final String partitionPrefix = "p_";
+    private LocalDateTime startTime;
+    private LocalDateTime endTime;
+
+    private DateTimeFormatter startDateTimeFormat;
+    private DateTimeFormatter endDateTimeFormat;
+
+
+    private Long timeInterval;
+    private final PartitionKeyDesc partitionKeyDesc;
+    private TimestampArithmeticExpr.TimeUnit timeUnitType;
+    private final Map<String, String> properties;
+    private final List<SinglePartitionDesc> singlePartitionDescList = 
Lists.newArrayList();
+
+    private final ImmutableSet<TimestampArithmeticExpr.TimeUnit> 
timeUnitTypeMultiPartition = ImmutableSet.of(
+            TimestampArithmeticExpr.TimeUnit.HOUR,
+            TimestampArithmeticExpr.TimeUnit.DAY,
+            TimestampArithmeticExpr.TimeUnit.WEEK,
+            TimestampArithmeticExpr.TimeUnit.MONTH,
+            TimestampArithmeticExpr.TimeUnit.YEAR
+    );
+
+    private final Integer maxAllowedLimit = Config.max_multi_partition_num;
+
+    public MultiPartitionDesc(PartitionKeyDesc partitionKeyDesc,
+                          Map<String, String> properties) throws 
AnalysisException {
+        this.partitionKeyDesc = partitionKeyDesc;
+        this.properties = properties;
+        this.timeIntervalTrans();
+        this.timeTrans();
+    }
+
+    public List<SinglePartitionDesc> getSinglePartitionDescList() throws 
AnalysisException {
+        if (singlePartitionDescList.size() == 0) {
+            buildMultiPartitionToSinglePartitionDescs();
+        }
+        return singlePartitionDescList;
+    }
+
+    private List<SinglePartitionDesc> 
buildMultiPartitionToSinglePartitionDescs() throws AnalysisException {
+        String partitionName;
+        long countNum = 0;
+        int dayOfWeek = 1;
+        int dayOfMonth = 1;
+        String partitionPrefix = this.partitionPrefix;
+        LocalDateTime startTime = this.startTime;
+        if (properties != null) {
+            if 
(properties.containsKey(DynamicPartitionProperty.START_DAY_OF_WEEK)) {
+                String dayOfWeekStr = 
properties.get(DynamicPartitionProperty.START_DAY_OF_WEEK);
+                try {
+                    DynamicPartitionUtil.checkStartDayOfWeek(dayOfWeekStr);
+                } catch (DdlException e) {
+                    throw new AnalysisException(e.getMessage());
+                }
+                dayOfWeek = Integer.parseInt(dayOfWeekStr);
+            }
+            if 
(properties.containsKey(DynamicPartitionProperty.START_DAY_OF_MONTH)) {
+                String dayOfMonthStr = 
properties.get(DynamicPartitionProperty.START_DAY_OF_MONTH);
+                try {
+                    DynamicPartitionUtil.checkStartDayOfMonth(dayOfMonthStr);

Review Comment:
   This piece of code is to solve the conflict between dynamic partitioning and 
multi partitioning at one create table sql. It is reasonable to refer to the 
params/methods  of dynamic partitions for judgment. These params/methods are 
still belong to dynamic partitions essentially, so I think they should  not be 
moved.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to