@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 testSchemaDoesntExistNoSchemaFoundException() throws SQLException {
    when(mockResultSet.next())
        // The Database exists check should pass, followed by Error code 2003 for Schema exists
        .thenReturn(true)
        .thenReturn(false)
        .thenThrow(new SQLException("Schema does not exist", "2000", 2003, null))
        // The Database exists check should pass, followed by Error code 2043 for Schema exists
        .thenReturn(true)
        .thenReturn(false)
        .thenThrow(
            new SQLException(
                "Schema does not exist, or operation cannot be performed", "2000", 2043, null))
        // The Database exists check should pass, followed by Error code 2001 for Schema exists
        .thenReturn(true)
        .thenReturn(false)
        .thenThrow(new SQLException("Schema does not exist or not authorized", "2000", 2001, null));

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

    // Error code 2003
    assertThat(snowflakeClient.schemaExists(SnowflakeIdentifier.ofSchema("DB_1", "SCHEMA_2")))
        .isFalse();

    // Error code 2043
    assertThat(snowflakeClient.schemaExists(SnowflakeIdentifier.ofSchema("DB_1", "SCHEMA_2")))
        .isFalse();

    // Error code 2001
    assertThat(snowflakeClient.schemaExists(SnowflakeIdentifier.ofSchema("DB_1", "SCHEMA_2")))
        .isFalse();
  }