@Override
  public List<SnowflakeIdentifier> listDatabases() {
    List<SnowflakeIdentifier> databases;
    try {
      databases =
          connectionPool.run(
              conn ->
                  queryHarness.query(
                      conn, "SHOW DATABASES IN ACCOUNT", DATABASE_RESULT_SET_HANDLER));
    } catch (SQLException e) {
      throw snowflakeExceptionToIcebergException(
          SnowflakeIdentifier.ofRoot(), e, "Failed to list databases");
    } catch (InterruptedException e) {
      throw new UncheckedInterruptedException(e, "Interrupted while listing databases");
    }
    databases.forEach(
        db ->
            Preconditions.checkState(
                db.type() == SnowflakeIdentifier.Type.DATABASE,
                "Expected DATABASE, got identifier '%s'",
                db));
    return databases;
  }
@SuppressWarnings("unchecked")
  @Test
  public void testListDatabasesInAccount() throws SQLException {
    when(mockResultSet.next()).thenReturn(true).thenReturn(true).thenReturn(true).thenReturn(false);
    when(mockResultSet.getString("name")).thenReturn("DB_1").thenReturn("DB_2").thenReturn("DB_3");

    List<SnowflakeIdentifier> actualList = snowflakeClient.listDatabases();

    verify(mockQueryHarness)
        .query(
            eq(mockConnection),
            eq("SHOW DATABASES IN ACCOUNT"),
            any(JdbcSnowflakeClient.ResultSetParser.class));

    assertThat(actualList)
        .containsExactly(
            SnowflakeIdentifier.ofDatabase("DB_1"),
            SnowflakeIdentifier.ofDatabase("DB_2"),
            SnowflakeIdentifier.ofDatabase("DB_3"));
  }