Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ public static DataProperty analyzeDataProperty(Map<String, String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,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"
Expand All @@ -1703,7 +1703,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"
Expand All @@ -1726,6 +1726,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
Expand Down