@Override
  public List<SnowflakeIdentifier> listIcebergTables(SnowflakeIdentifier scope) {
    StringBuilder baseQuery = new StringBuilder("SHOW ICEBERG TABLES");
    String[] queryParams = null;
    switch (scope.type()) {
      case ROOT:
        // account-level listing
        baseQuery.append(" IN ACCOUNT");
        break;
      case DATABASE:
        // database-level listing
        baseQuery.append(" IN DATABASE IDENTIFIER(?)");
        queryParams = new String[] {scope.toIdentifierString()};
        break;
      case SCHEMA:
        // schema-level listing
        baseQuery.append(" IN SCHEMA IDENTIFIER(?)");
        queryParams = new String[] {scope.toIdentifierString()};
        break;
      default:
        throw new IllegalArgumentException(
            String.format("Unsupported scope type for listIcebergTables: %s", scope));
    }

    final String finalQuery = baseQuery.toString();
    final String[] finalQueryParams = queryParams;
    List<SnowflakeIdentifier> tables;
    try {
      tables =
          connectionPool.run(
              conn ->
                  queryHarness.query(conn, finalQuery, TABLE_RESULT_SET_HANDLER, finalQueryParams));
    } catch (SQLException e) {
      throw snowflakeExceptionToIcebergException(
          scope, e, String.format("Failed to list tables for scope '%s'", scope));
    } catch (InterruptedException e) {
      throw new UncheckedInterruptedException(
          e, "Interrupted while listing tables for scope '%s'", scope);
    }
    tables.forEach(
        table ->
            Preconditions.checkState(
                table.type() == SnowflakeIdentifier.Type.TABLE,
                "Expected TABLE, got identifier '%s' for scope '%s'",
                table,
                scope));
    return tables;
  }
@SuppressWarnings("unchecked")
  @Test
  public void testListIcebergTablesSQLExceptionAtRootLevel()
      throws SQLException, InterruptedException {
    Exception injectedException =
        new SQLException(String.format("SQL exception with Error Code %d", 0), "2000", 0, null);
    when(mockClientPool.run(any(ClientPool.Action.class))).thenThrow(injectedException);

    assertThatExceptionOfType(UncheckedSQLException.class)
        .isThrownBy(() -> snowflakeClient.listIcebergTables(SnowflakeIdentifier.ofRoot()))
        .withMessageContaining("Failed to list tables for scope 'ROOT: '''")
        .withCause(injectedException);
  }