[fix](dynamic-partition) create HOUR unit partition with DATEV2 throw exception (#19213)
Need to forbid create HOUR unit partition with partition column type DATEV2 ``` Unexpected exception: String index out of range: 10 ```
This commit is contained in:
@ -87,11 +87,12 @@ public class DynamicPartitionUtil {
|
||||
RangePartitionInfo rangePartitionInfo = (RangePartitionInfo) partitionInfo;
|
||||
Preconditions.checkState(!rangePartitionInfo.isMultiColumnPartition());
|
||||
Column partitionColumn = rangePartitionInfo.getPartitionColumns().get(0);
|
||||
if ((partitionColumn.getDataType() == PrimitiveType.DATE)
|
||||
if ((partitionColumn.getDataType() == PrimitiveType.DATE
|
||||
|| partitionColumn.getDataType() == PrimitiveType.DATEV2)
|
||||
&& (timeUnit.equalsIgnoreCase(TimeUnit.HOUR.toString()))) {
|
||||
ErrorReport.reportDdlException(DynamicPartitionProperty.TIME_UNIT + " could not be "
|
||||
+ TimeUnit.HOUR.toString() + " when type of partition column "
|
||||
+ partitionColumn.getDisplayName() + " is " + PrimitiveType.DATE.toString());
|
||||
+ TimeUnit.HOUR + " when type of partition column "
|
||||
+ partitionColumn.getDisplayName() + " is " + PrimitiveType.DATE + " or " + PrimitiveType.DATEV2);
|
||||
} else if (PrimitiveType.getIntegerTypes().contains(partitionColumn.getDataType())
|
||||
&& timeUnit.equalsIgnoreCase(TimeUnit.HOUR.toString())) {
|
||||
// The partition column's type is INT, not support HOUR
|
||||
@ -462,7 +463,7 @@ public class DynamicPartitionUtil {
|
||||
}
|
||||
if (Strings.isNullOrEmpty(reservedHistoryPeriods)) {
|
||||
properties.put(DynamicPartitionProperty.RESERVED_HISTORY_PERIODS,
|
||||
String.valueOf(DynamicPartitionProperty.NOT_SET_RESERVED_HISTORY_PERIODS));
|
||||
DynamicPartitionProperty.NOT_SET_RESERVED_HISTORY_PERIODS);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -2237,7 +2237,6 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
new DataProperty(DataProperty.DEFAULT_STORAGE_MEDIUM));
|
||||
if (partitionInfo.getType() == PartitionType.RANGE) {
|
||||
DynamicPartitionUtil.checkAndSetDynamicPartitionProperty(olapTable, properties, db);
|
||||
|
||||
} else if (partitionInfo.getType() == PartitionType.LIST) {
|
||||
if (DynamicPartitionUtil.checkDynamicPartitionPropertiesExist(properties)) {
|
||||
throw new DdlException(
|
||||
|
||||
Reference in New Issue
Block a user