nastra commented on code in PR #10082: URL: https://github.com/apache/iceberg/pull/10082#discussion_r1553049382
########## core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java: ########## @@ -970,6 +976,51 @@ public void testCatalogWithCustomMetricsReporter() throws IOException { Assertions.assertThat(CustomMetricsReporter.COUNTER.get()).isEqualTo(2); } + @Test + public void testCommitExceptionWithoutMessage() { + TableIdentifier tableIdent = TableIdentifier.of("db", "ns1", "ns2", "tbl"); + BaseTable table = (BaseTable) catalog.buildTable(tableIdent, SCHEMA).create(); + JdbcTableOperations ops = (JdbcTableOperations) table.operations(); + TableMetadata metadataV1 = ops.current(); + + table.updateSchema().addColumn("n", Types.IntegerType.get()).commit(); + ops.refresh(); + + JdbcTableOperations spyOps = spy(ops); + + try (MockedStatic<JdbcUtil> mockedStatic = Mockito.mockStatic(JdbcUtil.class)) { + mockedStatic + .when(() -> JdbcUtil.loadTable(any(), any(), any(), any())) + .thenThrow(new SQLException()); + assertThatThrownBy(() -> spyOps.commit(ops.current(), metadataV1)) + .isInstanceOf(UncheckedSQLException.class) + .hasMessageStartingWith("Unknown failure"); + } + } + + @Test + public void testCommitExceptionWithMessage() { + TableIdentifier tableIdent = TableIdentifier.of("db", "ns1", "ns2", "tbl"); + BaseTable table = (BaseTable) catalog.buildTable(tableIdent, SCHEMA).create(); + JdbcTableOperations ops = (JdbcTableOperations) table.operations(); + + TableMetadata metadataV1 = ops.current(); + + table.updateSchema().addColumn("n", Types.IntegerType.get()).commit(); + ops.refresh(); + + JdbcTableOperations spyOps = spy(ops); + + try (MockedStatic<JdbcUtil> mockedStatic = Mockito.mockStatic(JdbcUtil.class)) { + mockedStatic + .when(() -> JdbcUtil.loadTable(any(), any(), any(), any())) + .thenThrow(new SQLException("constraint failed")); Review Comment: shouldn't this have a null message? -- 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