github-actions[bot] commented on code in PR #65219:
URL: https://github.com/apache/doris/pull/65219#discussion_r3529363350
##########
fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java:
##########
@@ -2313,4 +2518,478 @@ public void
testAutoPartitionRetentionTimestampTzCutoffNormalized() throws Excep
connectContext.getSessionVariable().setTimeZone(originalSessionTz);
}
}
+
+ @Test
+ public void testTimeStampTzGetHistoricalPartitionsRangeBased() throws
Exception {
+ // Verify that getHistoricalPartitions correctly identifies the current
+ // partition by range lower bound (currentUtcBorder) rather than by
name.
+ // When the configured timezone (e.g. Asia/Shanghai) is a day ahead of
UTC,
+ // the scheduler computes nowPartitionName from the TZ date (e.g.
"p20260707")
+ // while currentUtcBorder is from the UTC date ("2026-07-06
00:00:00+00:00").
+ // Name-based comparison would fail to exclude the real current
partition
+ // (p20260706), treating it as historical. Range-based comparison
correctly
+ // excludes it by matching the stored partition lower bound.
+
+ String createSql = "CREATE TABLE test.`tstz_hist_parts` (\n"
+ + " `k1` TIMESTAMPTZ NULL COMMENT \"\",\n"
+ + " `k2` int NULL COMMENT \"\"\n"
+ + ") ENGINE=OLAP\n"
+ + "DUPLICATE KEY(`k1`, `k2`)\n"
+ + "PARTITION BY RANGE(`k1`)\n"
+ + "()\n"
+ + "DISTRIBUTED BY HASH(`k2`) BUCKETS 3\n"
+ + "PROPERTIES (\n"
+ + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n"
+ + "\"dynamic_partition.start\" = \"-3\",\n"
+ + "\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"true\",\n"
+ + "\"dynamic_partition.time_unit\" = \"day\",\n"
+ + "\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n"
+ + "\"dynamic_partition.time_zone\" = \"Asia/Shanghai\"\n"
+ + ");";
+ createTable(createSql);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("tstz_hist_parts");
+
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(), table.getId());
+
+ int totalPartitions = table.getPartitionNames().size();
+ Assert.assertEquals(7, totalPartitions);
+
+ RangePartitionInfo info = (RangePartitionInfo)
table.getPartitionInfo();
+ DynamicPartitionProperty prop =
table.getTableProperty().getDynamicPartitionProperty();
+ String partitionFormat = DynamicPartitionUtil.getPartitionFormat(
+ info.getPartitionColumns().get(0));
+ ZonedDateTime utcNow = ZonedDateTime.now(ZoneOffset.UTC);
+ // getPartitionRangeString with DATETIME_FORMAT returns "yyyy-MM-dd
HH:mm:ss"
+ // (e.g. "2026-07-06 00:00:00"). convertToUtcTimestamp appends
"+00:00".
+ String utcBorderDateTime =
DynamicPartitionUtil.getPartitionRangeString(prop, utcNow, 0, partitionFormat);
+ String currentUtcBorder = utcBorderDateTime + "+00:00";
+
+ // Use a deliberately mismatched nowPartitionName to simulate the
scenario
+ // where the configured TZ and UTC disagree on the calendar date.
+ // Name-based comparison would NOT exclude any partition with this
name.
+ String wrongNowPartitionName = "p_nonexistent";
+
+ // 1. Without currentUtcBorder: name-based cannot identify the current
partition.
+ List<Partition> historicalNoUtc =
DynamicPartitionScheduler.getHistoricalPartitions(
+ table, wrongNowPartitionName, null);
+ boolean currentFoundByName = false;
+ for (Partition p : historicalNoUtc) {
+ RangePartitionItem item = (RangePartitionItem)
info.getItem(p.getId());
+ String lowerBound =
item.getItems().lowerEndpoint().getKeys().get(0).getStringValue();
+ if (lowerBound.equals(currentUtcBorder)) {
+ currentFoundByName = true;
+ break;
+ }
+ }
+ Assert.assertTrue("Name-based should fail to exclude current
partition: "
+ + "nowPartitionName='" + wrongNowPartitionName + "' does not
match any partition",
+ currentFoundByName);
+
+ // 2. With currentUtcBorder: range-based correctly excludes the
current partition.
+ List<Partition> historicalWithUtc =
DynamicPartitionScheduler.getHistoricalPartitions(
+ table, wrongNowPartitionName, currentUtcBorder);
+ boolean currentFoundByRange = false;
+ for (Partition p : historicalWithUtc) {
+ RangePartitionItem item = (RangePartitionItem)
info.getItem(p.getId());
+ String lowerBound =
item.getItems().lowerEndpoint().getKeys().get(0).getStringValue();
+ if (lowerBound.equals(currentUtcBorder)) {
+ currentFoundByRange = true;
+ break;
+ }
+ }
+ Assert.assertFalse("Range-based should correctly exclude the current
partition",
+ currentFoundByRange);
+ Assert.assertEquals("Should exclude exactly the current partition",
+ totalPartitions - 1, historicalWithUtc.size());
+ }
+
+ @Test
+ public void testTimeStampTzDynamicPartitionMonthUnit() throws Exception {
+ // Verify TIMESTAMPTZ dynamic partition with MONTH unit:
+ // boundaries are at UTC midnight (day=01 00:00:00+00:00),
+ // names use the configured timezone's calendar month.
+ String originalTimeZone =
connectContext.getSessionVariable().getTimeZone();
+ try {
+ connectContext.getSessionVariable().setTimeZone("America/Chicago");
+
+ String createOlapTblStmt = "CREATE TABLE
test.`timestamptz_dynamic_month` (\n"
+ + " `k1` TIMESTAMPTZ NULL COMMENT \"\",\n"
+ + " `k2` int NULL COMMENT \"\"\n"
+ + ") ENGINE=OLAP\n"
+ + "DUPLICATE KEY(`k1`, `k2`)\n"
+ + "PARTITION BY RANGE(`k1`)\n"
+ + "()\n"
+ + "DISTRIBUTED BY HASH(`k2`) BUCKETS 3\n"
+ + "PROPERTIES (\n"
+ + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n"
+ + "\"dynamic_partition.start\" = \"-3\",\n"
+ + "\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"true\",\n"
+ + "\"dynamic_partition.time_unit\" = \"month\",\n"
+ + "\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n"
+ + "\"dynamic_partition.time_zone\" = \"Asia/Shanghai\"\n"
+ + ");";
+ createTable(createOlapTblStmt);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("timestamptz_dynamic_month");
+ Assert.assertTrue(table.dynamicPartitionExists());
+
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(),
table.getId());
+
+ int partitionCount = table.getPartitionNames().size();
+ Assert.assertEquals(7, partitionCount);
+
+ // Verify partition boundaries are UTC midnight and names use
+ // configured timezone (Asia/Shanghai).
+ RangePartitionInfo partitionInfo = (RangePartitionInfo)
table.getPartitionInfo();
+ for (Map.Entry<Long, PartitionItem> entry :
partitionInfo.getIdToItem(false).entrySet()) {
+ RangePartitionItem item = (RangePartitionItem)
entry.getValue();
+ String partitionName =
table.getPartition(entry.getKey()).getName();
+ Assert.assertTrue("Partition name should start with 'p': " +
partitionName,
+ partitionName.startsWith("p"));
+ // Month partition names: p + yyyyMM → length 7
+ Assert.assertEquals("Month partition name length: " +
partitionName,
+ 7, partitionName.length());
+
+ // Verify range validity
+ Range<PartitionKey> range = item.getItems();
+ Assert.assertTrue("lower must be < upper",
+ range.lowerEndpoint().compareTo(range.upperEndpoint())
< 0);
+
+ // Partition boundaries must be UTC timestamps with +00:00
suffix.
+ List<LiteralExpr> lowerKeys = range.lowerEndpoint().getKeys();
+ Assert.assertEquals(1, lowerKeys.size());
+ String lowerStr = lowerKeys.get(0).getStringValue();
+ Assert.assertTrue("Lower key must be UTC with +00:00 suffix: "
+ lowerStr,
+ lowerStr.contains("+00:00"));
+
+ List<LiteralExpr> upperKeys = range.upperEndpoint().getKeys();
+ Assert.assertEquals(1, upperKeys.size());
+ String upperStr = upperKeys.get(0).getStringValue();
+ Assert.assertTrue("Upper key must be UTC with +00:00 suffix: "
+ upperStr,
+ upperStr.contains("+00:00"));
+
+ // Partition boundaries must be at UTC midnight (hour=00)
+ // regardless of time_zone. Day should be 01 (first of month).
+ String lowerDay = lowerStr.substring(8, 10);
+ Assert.assertEquals("Lower bound must be day 01 for month
unit: " + lowerStr,
+ "01", lowerDay);
+ String lowerHour = lowerStr.substring(11, 13);
+ Assert.assertEquals("Lower bound must be UTC midnight (00): "
+ lowerStr,
+ "00", lowerHour);
+ String upperHour = upperStr.substring(11, 13);
+ Assert.assertEquals("Upper bound must be UTC midnight (00): "
+ upperStr,
+ "00", upperHour);
+ }
+
+ // Verify the current partition (idx=0) name matches the UTC
+ // calendar month, since both names and values are UTC-based.
+ // Accept either the current or previous month in case the wall
+ // clock rolled over between scheduler execution and this
assertion.
+ ZonedDateTime utcNow = ZonedDateTime.now(ZoneOffset.UTC);
+ String expectedName = "p" +
DateTimeFormatter.ofPattern("yyyyMM").format(utcNow);
+ String prevExpectedName = "p" +
DateTimeFormatter.ofPattern("yyyyMM")
+ .format(utcNow.minusMonths(1));
+ Assert.assertTrue("Should find month partition '" + expectedName +
"' or '" + prevExpectedName
+ + "' named per UTC",
+ table.getPartitionNames().contains(expectedName)
+ || table.getPartitionNames().contains(prevExpectedName));
+ } finally {
+ connectContext.getSessionVariable().setTimeZone(originalTimeZone);
+ }
+ }
+
+ @Test
+ public void testTimeStampTzDynamicPartitionYearUnit() throws Exception {
+ // Verify TIMESTAMPTZ dynamic partition with YEAR unit:
+ // boundaries are at UTC midnight (month=01, day=01 00:00:00+00:00),
+ // names use the configured timezone's calendar year.
+ String originalTimeZone =
connectContext.getSessionVariable().getTimeZone();
+ try {
+ connectContext.getSessionVariable().setTimeZone("America/Chicago");
+
+ String createOlapTblStmt = "CREATE TABLE
test.`timestamptz_dynamic_year` (\n"
+ + " `k1` TIMESTAMPTZ NULL COMMENT \"\",\n"
+ + " `k2` int NULL COMMENT \"\"\n"
+ + ") ENGINE=OLAP\n"
+ + "DUPLICATE KEY(`k1`, `k2`)\n"
+ + "PARTITION BY RANGE(`k1`)\n"
+ + "()\n"
+ + "DISTRIBUTED BY HASH(`k2`) BUCKETS 3\n"
+ + "PROPERTIES (\n"
+ + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n"
+ + "\"dynamic_partition.start\" = \"-3\",\n"
+ + "\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"true\",\n"
+ + "\"dynamic_partition.time_unit\" = \"year\",\n"
+ + "\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n"
+ + "\"dynamic_partition.time_zone\" = \"Asia/Shanghai\"\n"
+ + ");";
+ createTable(createOlapTblStmt);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("timestamptz_dynamic_year");
+ Assert.assertTrue(table.dynamicPartitionExists());
+
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(),
table.getId());
+
+ int partitionCount = table.getPartitionNames().size();
+ Assert.assertEquals(7, partitionCount);
+
+ // Verify partition boundaries are UTC midnight and names use
+ // configured timezone (Asia/Shanghai).
+ RangePartitionInfo partitionInfo = (RangePartitionInfo)
table.getPartitionInfo();
+ for (Map.Entry<Long, PartitionItem> entry :
partitionInfo.getIdToItem(false).entrySet()) {
+ RangePartitionItem item = (RangePartitionItem)
entry.getValue();
+ String partitionName =
table.getPartition(entry.getKey()).getName();
+ Assert.assertTrue("Partition name should start with 'p': " +
partitionName,
+ partitionName.startsWith("p"));
+ // Year partition names: p + yyyy → length 5
+ Assert.assertEquals("Year partition name length: " +
partitionName,
+ 5, partitionName.length());
+
+ // Verify range validity
+ Range<PartitionKey> range = item.getItems();
+ Assert.assertTrue("lower must be < upper",
+ range.lowerEndpoint().compareTo(range.upperEndpoint())
< 0);
+
+ // Partition boundaries must be UTC timestamps with +00:00
suffix.
+ List<LiteralExpr> lowerKeys = range.lowerEndpoint().getKeys();
+ Assert.assertEquals(1, lowerKeys.size());
+ String lowerStr = lowerKeys.get(0).getStringValue();
+ Assert.assertTrue("Lower key must be UTC with +00:00 suffix: "
+ lowerStr,
+ lowerStr.contains("+00:00"));
+
+ List<LiteralExpr> upperKeys = range.upperEndpoint().getKeys();
+ Assert.assertEquals(1, upperKeys.size());
+ String upperStr = upperKeys.get(0).getStringValue();
+ Assert.assertTrue("Upper key must be UTC with +00:00 suffix: "
+ upperStr,
+ upperStr.contains("+00:00"));
+
+ // Partition boundaries must be at UTC midnight (hour=00)
+ // regardless of time_zone. Month should be 01, day should be
01.
+ String lowerMonth = lowerStr.substring(5, 7);
+ Assert.assertEquals("Lower bound must be month 01 for year
unit: " + lowerStr,
+ "01", lowerMonth);
+ String lowerDay = lowerStr.substring(8, 10);
+ Assert.assertEquals("Lower bound must be day 01 for year unit:
" + lowerStr,
+ "01", lowerDay);
+ String lowerHour = lowerStr.substring(11, 13);
+ Assert.assertEquals("Lower bound must be UTC midnight (00): "
+ lowerStr,
+ "00", lowerHour);
+ String upperHour = upperStr.substring(11, 13);
+ Assert.assertEquals("Upper bound must be UTC midnight (00): "
+ upperStr,
+ "00", upperHour);
+ }
+
+ // Verify the current partition (idx=0) name matches the UTC
+ // calendar year, since both names and values are UTC-based.
+ // Accept either the current or previous year in case the wall
+ // clock rolled over between scheduler execution and this
assertion.
+ ZonedDateTime utcNow = ZonedDateTime.now(ZoneOffset.UTC);
+ String expectedName = "p" +
DateTimeFormatter.ofPattern("yyyy").format(utcNow);
+ String prevExpectedName = "p" + DateTimeFormatter.ofPattern("yyyy")
+ .format(utcNow.minusYears(1));
+ Assert.assertTrue("Should find year partition '" + expectedName +
"' or '" + prevExpectedName
+ + "' named per UTC",
+ table.getPartitionNames().contains(expectedName)
+ || table.getPartitionNames().contains(prevExpectedName));
+ } finally {
+ connectContext.getSessionVariable().setTimeZone(originalTimeZone);
+ }
+ }
+
+ @Test
+ public void testTimeStampTzReservedHistoryPeriodsUtcAligned() throws
Exception {
+ // Verify that reserved_history_periods uses UTC-midnight boundaries
+ // (via borderTimeZone from getDropPartitionOpForDynamic) consistently
+ // with the main drop cutoff and add-partition boundaries.
+ // Without the fix, getClosedRange() hardcoded the configured timezone
+ // (e.g. Asia/Shanghai) for convertToUtcTimestamp(), shifting reserved
+ // ranges by the UTC offset and causing mismatches with UTC-aligned
+ // partition boundaries.
+ String originalTimeZone =
connectContext.getSessionVariable().getTimeZone();
+ try {
+ connectContext.getSessionVariable().setTimeZone("America/Chicago");
+
+ String createSql = "CREATE TABLE test.`tstz_reserved_hist` (\n"
+ + " `k1` TIMESTAMPTZ NULL COMMENT \"\",\n"
+ + " `k2` int NULL COMMENT \"\"\n"
+ + ") ENGINE=OLAP\n"
+ + "DUPLICATE KEY(`k1`, `k2`)\n"
+ + "PARTITION BY RANGE(`k1`)\n"
+ + "()\n"
+ + "DISTRIBUTED BY HASH(`k2`) BUCKETS 3\n"
+ + "PROPERTIES (\n"
+ + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n"
+ + "\"dynamic_partition.start\" = \"-3\",\n"
+ + "\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"false\",\n"
+ + "\"dynamic_partition.time_unit\" = \"day\",\n"
+ + "\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n"
+ + "\"dynamic_partition.time_zone\" = \"Asia/Shanghai\",\n"
+ + "\"dynamic_partition.reserved_history_periods\" =
\"[2019-06-01,2020-08-01]\"\n"
+ + ");";
+ createTable(createSql);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("tstz_reserved_hist");
+
+ // Add partitions manually — must temporarily disable dynamic
partition.
+ alterTable("ALTER TABLE test.tstz_reserved_hist SET "
+ + "('dynamic_partition.enable' = 'false')");
+ // Add a partition that falls within the reserved period with
+ // UTC-midnight boundaries: [2020-01-01 00:00 UTC, 2020-02-01
00:00 UTC).
+ // This should be protected by the reserved period.
+ alterTable("ALTER TABLE test.tstz_reserved_hist ADD PARTITION
p_202001 VALUES "
+ + "[('2020-01-01 00:00:00+00:00'), ('2020-02-01
00:00:00+00:00'))");
+ // Add a partition entirely before the reserved period.
+ // This should be dropped by the start=-3 cutoff.
+ alterTable("ALTER TABLE test.tstz_reserved_hist ADD PARTITION
p_old VALUES "
+ + "[('2018-01-01 00:00:00+00:00'), ('2018-02-01
00:00:00+00:00'))");
+
+ Assert.assertTrue("p_202001 should exist before scheduling",
+ table.getPartitionNames().contains("p_202001"));
+ Assert.assertTrue("p_old should exist before scheduling",
+ table.getPartitionNames().contains("p_old"));
+
+ // Re-enable dynamic partition and run the scheduler.
+ alterTable("ALTER TABLE test.tstz_reserved_hist SET "
+ + "('dynamic_partition.enable' = 'true')");
+
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(),
table.getId());
+
+ // p_202001 falls within reserved period [2019-06-01, 2020-08-01]
in
+ // UTC-midnight interpretation → must be kept.
+ Assert.assertTrue("p_202001 should be kept — within UTC-aligned
reserved history period",
+ table.getPartitionNames().contains("p_202001"));
+ // p_old is before the start=-3 cutoff and outside the reserved
+ // period → must be dropped.
+ Assert.assertFalse("p_old should be dropped — outside reserved
period and before start",
+ table.getPartitionNames().contains("p_old"));
+ } finally {
+ connectContext.getSessionVariable().setTimeZone(originalTimeZone);
+ }
+ }
+
+ @Test
+ public void testTimeStampTzHotPartitionCooldownUtcAligned() throws
Exception {
+ // Verify that hot-partition cooldown times are UTC-midnight aligned
+ // and not shifted by the configured timezone (America/Chicago, UTC-5).
+ // Without the fix, setStorageMediumProperty() used nowTz (configured
+ // timezone) which could place the cooldown boundary on a different
+ // calendar day than the partition's UTC range.
+ String originalTimeZone =
connectContext.getSessionVariable().getTimeZone();
+ try {
+ connectContext.getSessionVariable().setTimeZone("Asia/Shanghai");
+ changeBeDisk(TStorageMedium.SSD);
+
+ String createSql = "CREATE TABLE test.`tstz_hot_part_cooldown` (\n"
+ + " `k1` TIMESTAMPTZ NULL COMMENT \"\",\n"
+ + " `k2` int NULL COMMENT \"\"\n"
+ + ") ENGINE=OLAP\n"
+ + "DUPLICATE KEY(`k1`, `k2`)\n"
+ + "PARTITION BY RANGE(`k1`)\n"
+ + "()\n"
+ + "DISTRIBUTED BY HASH(`k2`) BUCKETS 3\n"
+ + "PROPERTIES (\n"
+ + "\"replication_num\" = \"1\",\n"
+ + "\"dynamic_partition.enable\" = \"true\",\n"
+ + "\"dynamic_partition.start\" = \"-3\",\n"
+ + "\"dynamic_partition.end\" = \"3\",\n"
+ + "\"dynamic_partition.create_history_partition\" =
\"true\",\n"
+ + "\"dynamic_partition.time_unit\" = \"day\",\n"
+ + "\"dynamic_partition.prefix\" = \"p\",\n"
+ + "\"dynamic_partition.buckets\" = \"1\",\n"
+ + "\"dynamic_partition.time_zone\" =
\"America/Chicago\",\n"
+ + "\"dynamic_partition.hot_partition_num\" = \"1\"\n"
+ + ");";
+ createTable(createSql);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("tstz_hot_part_cooldown");
+
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(),
table.getId());
+
+ RangePartitionInfo partitionInfo = (RangePartitionInfo)
table.getPartitionInfo();
+ // Sort partitions by lower bound.
+ List<Map.Entry<Long, PartitionItem>> sortedEntries =
Lists.newArrayList(
+ partitionInfo.getIdToItem(false).entrySet());
+ sortedEntries.sort((a, b) -> {
+ RangePartitionItem ai = (RangePartitionItem) a.getValue();
+ RangePartitionItem bi = (RangePartitionItem) b.getValue();
+ return
ai.getItems().lowerEndpoint().compareTo(bi.getItems().lowerEndpoint());
+ });
+
+ Assert.assertEquals(7, sortedEntries.size());
+
+ // Partitions idx=-3,-2,-1 are before the hot range → HDD.
+ // Partitions idx=0..3 (4 partitions) are within
hot_partition_num=1:
+ // - idx=0: hot (offset + hotPartitionNum = 0+1 = 1 > 0) → SSD
+ // - idx=1,2,3: hot (offset + hotPartitionNum > 0) → SSD
+ // Because hot_partition_num=1 means only the current partition is
hot,
+ // but the logic counts from idx + hotPartitionNum > 0.
+ // Actually: the condition is `offset + hotPartitionNum <= 0` →
HDD.
+ // So idx=-3,-2,-1: -3+1=-2≤0 HDD, -2+1=-1≤0 HDD, -1+1=0≤0 HDD.
+ // idx=0,1,2,3: 0+1=1>0 SSD, etc.
+ // idx=-3,-2,-1 are HDD, idx=0,1,2,3 are SSD.
+
+ for (int i = 0; i < sortedEntries.size(); i++) {
+ Map.Entry<Long, PartitionItem> entry = sortedEntries.get(i);
+ RangePartitionItem item = (RangePartitionItem)
entry.getValue();
+ DataProperty dp =
partitionInfo.getDataProperty(entry.getKey());
+
+ if (i < 3) {
+ // Historical partitions: HDD
+ Assert.assertEquals("Historical partition should be HDD:
idx=" + (i - 3),
+ TStorageMedium.HDD, dp.getStorageMedium());
+ } else {
+ // Hot partitions: SSD
+ Assert.assertEquals("Hot partition should be SSD: idx=" +
(i - 3),
+ TStorageMedium.SSD, dp.getStorageMedium());
+
+ // Cooldown time must be at UTC midnight (aligned with
+ // partition boundaries), not offset by America/Chicago.
+ if (dp.getCooldownTimeMs() !=
DataProperty.MAX_COOLDOWN_TIME_MS) {
Review Comment:
This new coverage still passes if the generated cooldown is missing or
unparseable, because the UTC checks are skipped whenever
`dp.getCooldownTimeMs()` is `DataProperty.MAX_COOLDOWN_TIME_MS`. That is
exactly the fallback `PropertyAnalyzer.analyzeDataProperty()` uses after a
`storage_cooldown_time` parse failure, so the test would not catch a regression
where the TIMESTAMPTZ lifecycle string is rejected. For this setup with
`hot_partition_num = 1`, each SSD partition should have a finite cooldown equal
to that partition's upper endpoint (`offset + hotPartitionNum`). Please assert
`cooldownTimeMs != MAX_COOLDOWN_TIME_MS` for every hot partition and compare
the instant to the partition upper bound, rather than only checking that any
finite value happens to be at UTC midnight.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]