@Override
  public List<SnowflakeIdentifier> listSchemas(SnowflakeIdentifier scope) {
    StringBuilder baseQuery = new StringBuilder("SHOW SCHEMAS");
    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;
      default:
        throw new IllegalArgumentException(
            String.format("Unsupported scope type for listSchemas: %s", scope));
    }

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

    assertThatExceptionOfType(UncheckedSQLException.class)
        .isThrownBy(() -> snowflakeClient.listSchemas(SnowflakeIdentifier.ofDatabase("DB_1")))
        .withMessageContaining("Failed to list schemas for scope 'DATABASE: 'DB_1''")
        .withCause(injectedException);
  }