lilei1128 commented on code in PR #7537:
URL: https://github.com/apache/paimon/pull/7537#discussion_r3446386304
##########
paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/action/CompactActionITCase.java:
##########
@@ -930,6 +932,127 @@ public void testDataEvolutionTableCompact() throws
Exception {
assertThat(value).isEqualTo(30000);
}
+ @Test
+ @Timeout(60)
+ public void testSkipExpiredPartitions() throws Exception {
+ // Use a date far in the past (expired) and today's date (not expired)
+ String expiredDt =
+
LocalDate.now().minusDays(30).format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+ String activeDt =
LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+
+ Map<String, String> tableOptions = new HashMap<>();
+ tableOptions.put(CoreOptions.WRITE_ONLY.key(), "true");
+ tableOptions.put(CoreOptions.PARTITION_EXPIRATION_TIME.key(), "7 d");
+ tableOptions.put(
+ CoreOptions.PARTITION_EXPIRATION_STRATEGY.key(),
+ CoreOptions.PartitionExpireStrategy.VALUES_TIME.toString());
+ tableOptions.put(CoreOptions.PARTITION_TIMESTAMP_FORMATTER.key(),
"yyyyMMdd");
+
+ FileStoreTable table =
+ prepareTable(
+ Collections.singletonList("dt"),
+ Arrays.asList("dt", "k"),
+ Collections.emptyList(),
+ tableOptions);
+
+ // Write two batches to each partition so each has multiple files
+ writeData(
+ rowData(1, 100, 15, BinaryString.fromString(expiredDt)),
+ rowData(1, 100, 15, BinaryString.fromString(activeDt)));
+
+ writeData(
+ rowData(2, 100, 15, BinaryString.fromString(expiredDt)),
+ rowData(2, 100, 15, BinaryString.fromString(activeDt)));
+
+ checkLatestSnapshot(table, 2, Snapshot.CommitKind.APPEND);
+
+ CompactAction action =
+ createAction(
+ CompactAction.class,
+ "compact",
+ "--warehouse",
+ warehouse,
+ "--database",
+ database,
+ "--table",
+ tableName,
+ "--table_conf",
+ CoreOptions.COMPACTION_SKIP_EXPIRED_PARTITIONS.key() +
"=true");
+ StreamExecutionEnvironment env =
streamExecutionEnvironmentBuilder().batchMode().build();
+ action.withStreamExecutionEnvironment(env).build();
+ env.execute();
+
+ checkLatestSnapshot(table, 3, Snapshot.CommitKind.COMPACT);
Review Comment:
Thanks for the review! I've added partition.expiration-check-interval=999
d to both test cases to make the tests deterministic and prevent partition
expiration from being triggered during the compact commit.
--
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]