@Override
  public boolean schemaExists(SnowflakeIdentifier schema) {
    Preconditions.checkArgument(
        schema.type() == SnowflakeIdentifier.Type.SCHEMA,
        "schemaExists requires a SCHEMA identifier, got '%s'",
        schema);

    if (!databaseExists(SnowflakeIdentifier.ofDatabase(schema.databaseName()))) {
      return false;
    }

    final String finalQuery = "SHOW TABLES IN SCHEMA IDENTIFIER(?) LIMIT 1";

    try {
      connectionPool.run(
          conn ->
              queryHarness.query(
                  conn, finalQuery, TABLE_RESULT_SET_HANDLER, schema.toIdentifierString()));
    } catch (SQLException e) {
      if (SCHEMA_NOT_FOUND_ERROR_CODES.contains(e.getErrorCode())) {
        return false;
      }
      throw new UncheckedSQLException(e, "Failed to check if schema '%s' exists", schema);
    } catch (InterruptedException e) {
      throw new UncheckedInterruptedException(
          e, "Interrupted while checking if schema '%s' exists", schema);
    }

    return true;
  }
@Test
  public void testSchemaFailureWithOtherException() throws SQLException {
    Exception injectedException = new SQLException("Some other exception", "2000", 2, null);
    when(mockResultSet.next())
        // The Database exists check should pass, followed by Error code 2 for Schema exists
        .thenReturn(true)
        .thenReturn(false)
        .thenThrow(injectedException);

    when(mockResultSet.getString("name")).thenReturn("DB1").thenReturn("SCHEMA1");
    when(mockResultSet.getString("database_name")).thenReturn("DB1");

    assertThatExceptionOfType(UncheckedSQLException.class)
        .isThrownBy(
            () -> snowflakeClient.schemaExists(SnowflakeIdentifier.ofSchema("DB_1", "SCHEMA_2")))
        .withMessageContaining("Failed to check if schema 'SCHEMA: 'DB_1.SCHEMA_2'' exists")
        .withCause(injectedException);
  }