AnubhavSiddharth commented on code in PR #6952:
URL: https://github.com/apache/iceberg/pull/6952#discussion_r1125063665


##########
snowflake/src/test/java/org/apache/iceberg/snowflake/JdbcSnowflakeClientTest.java:
##########
@@ -367,15 +535,66 @@ public void testListIcebergTablesInSchema() throws 
SQLException {
 
   /**
    * Any unexpected SQLException from the underlying connection will propagate 
out as an
-   * UncheckedSQLException when listing tables.
+   * UncheckedSQLException when listing tables at Root level
    */
   @Test
-  public void testListIcebergTablesSQLException() throws SQLException, 
InterruptedException {
-    when(mockClientPool.run(any(ClientPool.Action.class)))
-        .thenThrow(new SQLException("Fake SQL exception"));
-    Assertions.assertThatExceptionOfType(UncheckedSQLException.class)
-        .isThrownBy(() -> 
snowflakeClient.listIcebergTables(SnowflakeIdentifier.ofDatabase("DB_1")))
-        .withStackTraceContaining("Fake SQL exception");
+  public void testListIcebergTablesSQLExceptionAtRootLevel()
+      throws SQLException, InterruptedException {
+    generateExceptionAndAssert(
+        () -> snowflakeClient.listIcebergTables(SnowflakeIdentifier.ofRoot()),
+        new SQLException(String.format("SQL exception with Error Code %d", 0), 
"2000", 0, null),
+        UncheckedSQLException.class);
+  }
+
+  /**
+   * Any unexpected SQLException with specific error codes from the underlying 
connection will
+   * propagate out as a NoSuchNamespaceException when listing tables at 
Database level
+   */
+  @Test
+  public void testListIcebergTablesSQLExceptionAtDatabaseLevel()
+      throws SQLException, InterruptedException {
+    for (Integer errorCode : DATABASE_NOT_FOUND_ERROR_CODES) {
+      generateExceptionAndAssert(
+          () -> 
snowflakeClient.listIcebergTables(SnowflakeIdentifier.ofDatabase("DB_1")),
+          new SQLException(
+              String.format("SQL exception with Error Code %d", errorCode),
+              "2000",
+              errorCode,
+              null),
+          NoSuchNamespaceException.class);
+    }
+  }
+
+  /**
+   * Any unexpected SQLException with specific error codes from the underlying 
connection will
+   * propagate out as a NoSuchNamespaceException when listing tables at Schema 
level
+   */
+  @Test
+  public void testListIcebergTablesSQLExceptionAtSchemaLevel()
+      throws SQLException, InterruptedException {
+    for (Integer errorCode : SCHEMA_NOT_FOUND_ERROR_CODES) {

Review Comment:
   Makes sense, I've made the suggested changes



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

Reply via email to