stevenzwu commented on code in PR #11144: URL: https://github.com/apache/iceberg/pull/11144#discussion_r1776099559
########## flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/operator/TestExpireSnapshotsProcessor.java: ########## @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.iceberg.flink.maintenance.operator; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.Queue; +import java.util.Set; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness; +import org.apache.flink.streaming.util.ProcessFunctionTestHarnesses; +import org.apache.iceberg.SerializableTable; +import org.apache.iceberg.Snapshot; +import org.apache.iceberg.Table; +import org.apache.iceberg.flink.TableLoader; +import org.apache.iceberg.relocated.com.google.common.collect.Sets; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +class TestExpireSnapshotsProcessor extends OperatorTestBase { + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void testExpire(boolean success) throws Exception { + sql.exec("CREATE TABLE %s (id int, data varchar, spec varchar)", TABLE_NAME); + sql.exec("INSERT INTO %s VALUES (1, 'a', 'p1')", TABLE_NAME); + sql.exec("INSERT INTO %s VALUES (2, 'b', 'p2')", TABLE_NAME); + + TableLoader tableLoader = sql.tableLoader(TABLE_NAME); + Table table = tableLoader.loadTable(); + SerializableTable serializableTable = (SerializableTable) SerializableTable.copyOf(table); + + List<TaskResult> actual; + Queue<StreamRecord<String>> deletes; + try (OneInputStreamOperatorTestHarness<Trigger, TaskResult> testHarness = + ProcessFunctionTestHarnesses.forProcessFunction( + new ExpireSnapshotsProcessor(tableLoader, 0L, 1, 10))) { + testHarness.open(); + + if (!success) { + // Cause an exception + sql.exec("DROP TABLE IF EXISTS %s", TABLE_NAME); + } + + testHarness.processElement( + Trigger.create(10, serializableTable, 11), System.currentTimeMillis()); Review Comment: > We need a Table which is earlier than the element timestamp. currently, `ExpireSnapshotsProcessor` loads the table from `TableLoader`. > Or simply drop the state of the tablemanager It is not friendly to ask users to change operator uid for that purpose. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org