manuzhang commented on code in PR #13125: URL: https://github.com/apache/iceberg/pull/13125#discussion_r2132440552
########## spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestTagDDL.java: ########## @@ -355,6 +355,36 @@ public void createOrReplaceWithNonExistingTag() throws NoSuchTableException { assertThat(table.refs().get(tagName).snapshotId()).isEqualTo(snapshotId); } + @TestTemplate + public void testTagUpdatedAfterReplace() throws NoSuchTableException { + Table table = insertRows(); + long firstSnapshot = table.currentSnapshot().snapshotId(); + String tag1 = "t1"; + sql("ALTER TABLE %s CREATE OR REPLACE TAG %s", tableName, tag1); + sql("UPDATE %s SET data = 'b' WHERE id = 1", tableName); + String tag2 = "t2"; + sql("ALTER TABLE %s CREATE OR REPLACE TAG %s", tableName, tag2); + + table.refresh(); + assertThat(table.refs().get(tag1).snapshotId()) + .as("tag1 needs to point to first snapshot id.") + .isEqualTo(firstSnapshot); + assertThat(table.refs().get(tag2).snapshotId()) + .as("tag2 needs to point to current snapshot id.") + .isEqualTo(table.currentSnapshot().snapshotId()); + + sql( + "CALL %s.system.rewrite_data_files(table => '%s', options => map('rewrite-all','true'))", + catalogName, tableIdent); + table.refresh(); + assertThat(table.refs().get(tag1).snapshotId()) + .as("tag1 should not be changed.") + .isEqualTo(firstSnapshot); + assertThat(table.refs().get(tag2).snapshotId()) + .as("The tag needs to be updated after replace operation.") + .isEqualTo(table.currentSnapshot().snapshotId()); Review Comment: Thanks for review, let me think more about it. -- 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