morningman commented on a change in pull request #1679: Add fixed partitions URL: https://github.com/apache/incubator-doris/pull/1679#discussion_r325623854
########## File path: fe/src/main/java/org/apache/doris/catalog/RangePartitionInfo.java ########## @@ -93,12 +93,60 @@ public void addPartition(long partitionId, Range<PartitionKey> range, DataProper } public Range<PartitionKey> checkAndCreateRange(SingleRangePartitionDesc desc) throws DdlException { + List<Map.Entry<Long, Range<PartitionKey>>> entries = + new ArrayList<Map.Entry<Long, Range<PartitionKey>>>(this.idToRange.entrySet()); + Collections.sort(entries, RANGE_MAP_ENTRY_COMPARATOR); + PartitionKeyDesc partKeyDesc = desc.getPartitionKeyDesc(); + if (partKeyDesc.getLowerValues().isEmpty()) { + return handleLessThanRange(desc, entries); + } else { + return handleFixedRange(desc, entries); + } + } + + private Range<PartitionKey> handleFixedRange(SingleRangePartitionDesc desc, List<Map.Entry<Long, Range<PartitionKey>>> entries) throws DdlException { + Range<PartitionKey> newRange = null; + PartitionKeyDesc partKeyDesc = desc.getPartitionKeyDesc(); + try { + PartitionKey lowKey = + PartitionKey.createPartitionKey(partKeyDesc.getLowerValues(), partitionColumns); + PartitionKey upperKey = + PartitionKey.createPartitionKey(partKeyDesc.getUpperValues(), partitionColumns); + + // check: [left, right), error if left equal right + if (lowKey.compareTo(upperKey) == 0) { + throw new IllegalArgumentException("The right value must be more than the left value"); + } + + // new Range object + newRange = Range.closedOpen(lowKey, upperKey); + + // compare + for (Map.Entry<Long, Range<PartitionKey>> entry : entries) { + Range<PartitionKey> nextRange = entry.getValue(); + checkRangeIntersect(newRange, nextRange); + //keys only have one. Review comment: Why just check first key? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org