joyhaldar commented on code in PR #15308:
URL: https://github.com/apache/iceberg/pull/15308#discussion_r2839783984
##########
bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBigQueryTableOperations.java:
##########
@@ -288,4 +294,44 @@ private static Optional<String> metadataFilePath(String
tableDir) throws IOExcep
return Optional.empty();
}
+
+ private TableMetadata createTestMetadata() {
+ return TableMetadata.newTableMetadata(
+ SCHEMA,
+ PartitionSpec.unpartitioned(),
+ SortOrder.unsorted(),
+ tempFolder.getPath() + "/test-table",
+ ImmutableMap.of());
+ }
+
+ @Test
+ public void testCommitFailedExceptionThrowsDirectly() {
+ // CommitFailedException should fail immediately without retry or status
checks
+ when(client.load(TABLE_REFERENCE)).thenThrow(new
NoSuchTableException("Table not found"));
+ when(client.create(any(), any())).thenThrow(new
CommitFailedException("Commit rejected"));
+
+ tableOps.refresh();
+
+ assertThatThrownBy(() -> tableOps.commit(null, createTestMetadata()))
+ .isInstanceOf(CommitFailedException.class)
+ .hasMessage("Commit rejected");
+
+ verify(client, times(1)).create(any(Table.class),
any(RetryDetector.class));
+ verify(client, times(1)).load(TABLE_REFERENCE);
+ }
+
+ @Test
+ public void testRuntimeIOExceptionTriggersCommitStatusCheck() {
+ // RuntimeIOException should trigger commit status check as the commit may
have succeeded
+ when(client.load(TABLE_REFERENCE)).thenThrow(new
NoSuchTableException("Table not found"));
+ when(client.create(any(), any())).thenThrow(new
RuntimeIOException("Network error"));
+
+ tableOps.refresh();
+
+ assertThatThrownBy(() -> tableOps.commit(null, createTestMetadata()))
+ .isInstanceOf(CommitStateUnknownException.class)
+ .hasMessageContaining("Network error");
+
+ verify(client, atLeast(2)).load(TABLE_REFERENCE);
+ }
Review Comment:
The two tests cover the main cases, skipping status check for
`CommitFailedException` and triggering it for `RuntimeIOException`.
`AlreadyExistsException` goes through the same `catch (Throwable e)` block.
--
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]