This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 9ebc0757bb5 [fix](create table) Enhance the robustness of time zone handling during table creation (#41926) 9ebc0757bb5 is described below commit 9ebc0757bb5c89212d991d2dfd1ad99c57d8c8bf Author: deardeng <565620...@qq.com> AuthorDate: Tue Oct 22 00:21:37 2024 +0800 [fix](create table) Enhance the robustness of time zone handling during table creation (#41926) --- .../apache/doris/common/util/PropertyAnalyzer.java | 9 +++++-- .../doris/catalog/DynamicPartitionTableTest.java | 30 ++++++++++++++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) 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 8e1a05c9de5..238250ab37a 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 @@ -344,8 +344,13 @@ public class PropertyAnalyzer { 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 2ae051e4f25..4217342133b 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 @@ -1677,7 +1677,7 @@ public class DynamicPartitionTableTest { @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" @@ -1703,7 +1703,7 @@ public class DynamicPartitionTableTest { "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" @@ -1726,6 +1726,32 @@ public class DynamicPartitionTableTest { + "\"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 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org