github-actions[bot] commented on code in PR #64795:
URL: https://github.com/apache/doris/pull/64795#discussion_r3490737402
##########
fe/fe-core/src/test/java/org/apache/doris/catalog/DynamicPartitionTableTest.java:
##########
@@ -2014,4 +2016,216 @@ public void testAutoBuckets() throws Exception {
// due to partition size eq 0, use previous partition's(54th) bucket
num
Assert.assertEquals(53, partitions.get(partitions.size() -
1).getDistributionInfo().getBucketNum());
}
+
+ @Test
+ public void testTimeStampTzDynamicPartition() throws Exception {
+ // Set session timezone to something different from the partition
timezone
+ // to verify scheduler does not incorrectly use session timezone via
ConnectContext fallback.
+ String originalTimeZone =
connectContext.getSessionVariable().getTimeZone();
+ try {
+ connectContext.getSessionVariable().setTimeZone("Asia/Shanghai");
+
+ String createOlapTblStmt = "CREATE TABLE
test.`timestamptz_dynamic_partition` (\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/New_York\"\n"
+ + ");";
+ createTable(createOlapTblStmt);
+
+ Database db =
Env.getCurrentInternalCatalog().getDbOrAnalysisException("test");
+ OlapTable table = (OlapTable)
db.getTableOrAnalysisException("timestamptz_dynamic_partition");
+ Assert.assertTrue(table.dynamicPartitionExists());
+
+ // Execute dynamic partition scheduling
+ Env.getCurrentEnv().getDynamicPartitionScheduler()
+ .executeDynamicPartitionFirstTime(db.getId(),
table.getId());
+
+ // Verify total partitions (7 = start(-3) to end(3), inclusive)
+ int partitionCount = table.getPartitionNames().size();
+ Assert.assertEquals(7, partitionCount);
+
+ // Verify partition names are clean and partition values are UTC
timestamps
+ RangePartitionInfo partitionInfo = (RangePartitionInfo)
table.getPartitionInfo();
+ for (Map.Entry<Long, PartitionItem> entry :
partitionInfo.getIdToItem(false).entrySet()) {
+ RangePartitionItem item = (RangePartitionItem)
entry.getValue();
+
+ // Verify the partition name is clean
+ String partitionName =
table.getPartition(entry.getKey()).getName();
+ Assert.assertTrue("Partition name should start with 'p': " +
partitionName,
+ partitionName.startsWith("p"));
+ Assert.assertEquals("Partition name should be exactly 9 chars
(p + yyyyMMdd): " + partitionName,
+ 9, partitionName.length());
+
+ // Verify the range endpoints are valid and correctly ordered
+ Range<PartitionKey> range = item.getItems();
+ PartitionKey lower = range.lowerEndpoint();
+ PartitionKey upper = range.upperEndpoint();
+ Assert.assertTrue("lower must be < upper: " + range,
+ lower.compareTo(upper) < 0);
+
+ // Verify partition keys are UTC timestamps (with +00:00
suffix)
+ List<LiteralExpr> lowerKeys = lower.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 = upper.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"));
+
+ // The lower key hour should NOT be 0 for America/New_York
timezone
Review Comment:
These assertions do not actually prove the fix uses
`dynamic_partition.time_zone`. This test sets the session timezone to
`Asia/Shanghai` and the table property to `America/New_York`, but then it only
checks that each bound has a `+00:00` suffix and that the lower hour is not
`00`. If the scheduler regressed to converting the generated borders with the
session timezone instead, an Asia/Shanghai midnight boundary would still
serialize as a UTC-suffixed non-midnight value, so the test would pass while
creating the wrong range. Please assert the exact expected lower/upper UTC
instants for the configured dynamic-partition timezone, or add a fixed case
such as table timezone `+00:00` with a non-UTC session where the lower bound
must remain `00:00:00+00:00`.
--
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]