rdblue commented on code in PR #19187:
URL: https://github.com/apache/iceberg/pull/19187#discussion_r4744749484


##########
core/src/test/java/org/apache/iceberg/TestTransaction.java:
##########
@@ -49,6 +50,128 @@
 @ExtendWith(ParameterizedTestExtension.class)
 public class TestTransaction extends TestBase {
 
+  @TestTemplate
+  public void retriedFastAppendKeepsMetadataOfStagedManifest() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+
+    Transaction txn = table.newTransaction();
+    txn.newFastAppend().appendFile(FILE_A).commit();
+    // lists the manifest of FILE_A that the transaction staged
+    txn.newFastAppend().appendFile(FILE_B).commit();
+
+    // a concurrent commit makes the transaction retry, which gives the staged 
manifest a new
+    // sequence number and first row ID
+    table.newFastAppend().appendFile(FILE_C).commit();
+    txn.commitTransaction();
+
+    assertInheritsRetriedMetadata(FILE_A);
+  }
+
+  @TestTemplate
+  public void retriedMergeAppendKeepsMetadataOfStagedManifest() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+    table.updateProperties().set(TableProperties.MANIFEST_MIN_MERGE_COUNT, 
"2").commit();
+
+    Transaction txn = table.newTransaction();
+    txn.newAppend().appendFile(FILE_A).commit();
+    // merges its new manifest with the manifest of FILE_A that the 
transaction staged
+    txn.newAppend().appendFile(FILE_B).commit();
+
+    table.newFastAppend().appendFile(FILE_C).commit();
+    txn.commitTransaction();
+
+    assertInheritsRetriedMetadata(FILE_A);
+  }
+
+  @TestTemplate
+  public void retriedDeleteKeepsMetadataOfStagedManifestsItMerges() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+    table.updateProperties().set(TableProperties.MANIFEST_MIN_MERGE_COUNT, 
"2").commit();
+
+    Transaction txn = table.newTransaction();
+    txn.newFastAppend().appendFile(FILE_A).commit();
+    txn.newFastAppend().appendFile(FILE_B).commit();
+    // merges the two manifests that the transaction staged, with no new 
manifest of its own
+    txn.newDelete().deleteFile(FILE_D).commit();

Review Comment:
   I think this test needs to make assertions about the table state between 
operations to verify that it is testing what is intended.



##########
core/src/test/java/org/apache/iceberg/TestTransaction.java:
##########
@@ -49,6 +50,128 @@
 @ExtendWith(ParameterizedTestExtension.class)
 public class TestTransaction extends TestBase {
 
+  @TestTemplate
+  public void retriedFastAppendKeepsMetadataOfStagedManifest() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+
+    Transaction txn = table.newTransaction();
+    txn.newFastAppend().appendFile(FILE_A).commit();
+    // lists the manifest of FILE_A that the transaction staged
+    txn.newFastAppend().appendFile(FILE_B).commit();
+
+    // a concurrent commit makes the transaction retry, which gives the staged 
manifest a new
+    // sequence number and first row ID
+    table.newFastAppend().appendFile(FILE_C).commit();
+    txn.commitTransaction();
+
+    assertInheritsRetriedMetadata(FILE_A);
+  }
+
+  @TestTemplate
+  public void retriedMergeAppendKeepsMetadataOfStagedManifest() {
+    assumeThat(formatVersion).isGreaterThanOrEqualTo(2);
+    table.updateProperties().set(TableProperties.MANIFEST_MIN_MERGE_COUNT, 
"2").commit();
+
+    Transaction txn = table.newTransaction();
+    txn.newAppend().appendFile(FILE_A).commit();
+    // merges its new manifest with the manifest of FILE_A that the 
transaction staged
+    txn.newAppend().appendFile(FILE_B).commit();
+
+    table.newFastAppend().appendFile(FILE_C).commit();
+    txn.commitTransaction();
+
+    assertInheritsRetriedMetadata(FILE_A);
+  }
+
+  @TestTemplate
+  public void retriedDeleteKeepsMetadataOfStagedManifestsItMerges() {

Review Comment:
   The fact that this is triggered by a delete doesn't matter, right? I think 
this is overly specific.
   
   The main thing is that this is triggering a rewrite of uncommitted manifests 
by `ManifestMergeManager`. The test should reflect that and not have additional 
details.



-- 
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]

Reply via email to