Akash3121 commented on code in PR #10851:
URL: https://github.com/apache/paimon/pull/10851#discussion_r4437909944
##########
paimon-core/src/main/java/org/apache/paimon/partition/PartitionExpireStrategy.java:
##########
@@ -78,13 +77,43 @@ public List<String> toPartitionValue(Object[] array) {
return list;
}
+ /**
+ * Whether {@link #convertPartition} renders the value at this index in a
form meant for time
+ * extraction that can differ from the stored partition name.
+ */
+ public boolean isNormalizedForTimeExtraction(int index) {
+ switch
(toObjectArrayConverter.rowType().getTypeAt(index).getTypeRoot()) {
+ case DATE:
+ case TIMESTAMP_WITHOUT_TIME_ZONE:
+ case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
public Object[] convertPartition(BinaryRow partition) {
Object[] values = toObjectArrayConverter.convert(partition);
RowType partitionType = toObjectArrayConverter.rowType();
for (int index = 0; index < values.length; index++) {
- if (values[index] != null
- && partitionType.getTypeAt(index).getTypeRoot() ==
DataTypeRoot.DATE) {
- values[index] = LocalDate.ofEpochDay((Integer) values[index]);
+ if (values[index] == null) {
+ continue;
+ }
+ DataType type = partitionType.getTypeAt(index);
+ switch (type.getTypeRoot()) {
+ case DATE:
+ values[index] = LocalDate.ofEpochDay((Integer)
values[index]);
+ break;
+ case TIMESTAMP_WITHOUT_TIME_ZONE:
+ case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
+ // Timestamp#toString uses the ISO 'T' separator, which
the default
+ // partition time formatter cannot parse. Render it as the
SQL string.
+ values[index] =
+ DateTimeUtils.formatTimestamp(
Review Comment:
This handles `TIMESTAMP_LTZ` as if it were a timezone-free `TIMESTAMP`. The
standard `TimestampToStringCastRule` formats LTZ values with
`TimeZone.getDefault()`, so in a non-UTC timezone this can shift the extracted
partition time-and even its date-relative to the logical/stored current-format
partition value. Could we use the timezone-aware overload for
`TIMESTAMP_WITH_LOCAL_TIME_ZONE` and add a regression test with a non-UTC
default timezone?
--
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]