diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java index 553b322076a0ca..8967e928d6344f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java @@ -258,8 +258,13 @@ public static DataProperty analyzeDataProperty(Map properties, f throw new AnalysisException("Invalid storage medium: " + value); } } else if (key.equalsIgnoreCase(PROPERTIES_STORAGE_COOLDOWN_TIME)) { - DateLiteral dateLiteral = new DateLiteral(value, ScalarType.getDefaultDateType(Type.DATETIME)); - cooldownTimestamp = dateLiteral.unixTimestamp(TimeUtils.getTimeZone()); + try { + DateLiteral dateLiteral = new DateLiteral(value, ScalarType.getDefaultDateType(Type.DATETIME)); + cooldownTimestamp = dateLiteral.unixTimestamp(TimeUtils.getTimeZone()); + } catch (AnalysisException e) { + LOG.warn("dateLiteral failed, use max cool down time", e); + cooldownTimestamp = DataProperty.MAX_COOLDOWN_TIME_MS; + } } else if (key.equalsIgnoreCase(PROPERTIES_STORAGE_POLICY)) { hasStoragePolicy = true; newStoragePolicy = value; diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java index 23adb61eee38e7..f71be8113f97b0 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java @@ -1676,7 +1676,7 @@ public void testNoPartition() throws AnalysisException { @Test public void testHourUnitWithDateType() throws AnalysisException { - String createOlapTblStmt = "CREATE TABLE if not exists test.hour_with_date (\n" + String createOlapTblStmt = "CREATE TABLE if not exists test.hour_with_date1 (\n" + " `days` DATEV2 NOT NULL,\n" + " `hours` char(2) NOT NULL,\n" + " `positionID` char(20)\n" @@ -1702,7 +1702,7 @@ public void testHourUnitWithDateType() throws AnalysisException { "could not be HOUR when type of partition column days is DATE or DATEV2", () -> createTable(createOlapTblStmt)); - String createOlapTblStmt2 = "CREATE TABLE if not exists test.hour_with_date (\n" + String createOlapTblStmt2 = "CREATE TABLE if not exists test.hour_with_date2 (\n" + " `days` DATETIMEV2 NOT NULL,\n" + " `hours` char(2) NOT NULL,\n" + " `positionID` char(20)\n" @@ -1725,6 +1725,32 @@ public void testHourUnitWithDateType() throws AnalysisException { + "\"dynamic_partition.create_history_partition\" = \"true\"\n" + ");"; ExceptionChecker.expectThrowsNoException(() -> createTable(createOlapTblStmt2)); + + connectContext.getSessionVariable().setTimeZone("Asia/Tokyo"); + String createOlapTblStmt3 = "CREATE TABLE if not exists test.hour_with_date3 (\n" + + " `days` DATETIMEV2 NOT NULL,\n" + + " `hours` char(2) NOT NULL,\n" + + " `positionID` char(20)\n" + + " )\n" + + "UNIQUE KEY(`days`,`hours`,`positionID`)\n" + + "PARTITION BY RANGE(`days`) ()\n" + + "DISTRIBUTED BY HASH(`positionID`) BUCKETS AUTO\n" + + "PROPERTIES (\n" + + "\"replication_num\" = \"1\",\n" + + "\"compression\" = \"zstd\",\n" + + "\"enable_unique_key_merge_on_write\" = \"true\",\n" + + "\"light_schema_change\" = \"true\",\n" + + "\"dynamic_partition.enable\" = \"true\",\n" + + "\"dynamic_partition.time_unit\" = \"HOUR\",\n" + + "\"dynamic_partition.start\" = \"-24\",\n" + + "\"dynamic_partition.end\" = \"24\",\n" + + "\"dynamic_partition.prefix\" = \"p\",\n" + + "\"dynamic_partition.buckets\" = \"2\",\n" + + "\"dynamic_partition.hot_partition_num\" = \"0\",\n" + + "\"dynamic_partition.storage_medium\" = \"HDD\", \n" + + "\"dynamic_partition.create_history_partition\" = \"true\"\n" + + ");"; + ExceptionChecker.expectThrowsNoException(() -> createTable(createOlapTblStmt3)); } @Test