diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java index be0bfac66..82f887ed3 100644 --- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java +++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java @@ -88,9 +88,14 @@ public void testGetColumn() throws SQLException { statement = connection.createStatement(); databaseMetaData = connection.getMetaData(); + // Exclude SNOWFLAKE system database from DatabaseMetadata + ResultSet snowflakeResultSet = databaseMetaData.getColumns("SNOWFLAKE", null, null, null); + int numSnowflakeColumns = getSizeOfResultSet(snowflakeResultSet); + resultSet = databaseMetaData.getColumns(null, null, null, null); assertEquals( - getAllObjectCountInDBViaInforSchema(getAllColumnsCount), getSizeOfResultSet(resultSet)); + getAllObjectCountInDBViaInforSchema(getAllColumnsCount), + getSizeOfResultSet(resultSet) - numSnowflakeColumns); resultSet = databaseMetaData.getColumns(null, "JDBC_SCHEMA11", null, null); assertEquals(3, getSizeOfResultSet(resultSet)); @@ -242,13 +247,19 @@ public void testGetSchema() throws SQLException { databaseMetaData = connection.getMetaData(); assertEquals("schema", databaseMetaData.getSchemaTerm()); + // Exclude SNOWFLAKE system database from DatabaseMetadata + ResultSet snowflakeResultSet = databaseMetaData.getSchemas("SNOWFLAKE", null); + int numSnowflakeSchemas = getSizeOfResultSet(snowflakeResultSet); + resultSet = databaseMetaData.getSchemas(); assertEquals( - getAllObjectCountInDBViaInforSchema(getSchemaCount), getSizeOfResultSet(resultSet)); + getAllObjectCountInDBViaInforSchema(getSchemaCount), + getSizeOfResultSet(resultSet) - numSnowflakeSchemas); resultSet = databaseMetaData.getSchemas(null, null); assertEquals( - getAllObjectCountInDBViaInforSchema(getSchemaCount), getSizeOfResultSet(resultSet)); + getAllObjectCountInDBViaInforSchema(getSchemaCount), + getSizeOfResultSet(resultSet) - numSnowflakeSchemas); resultSet = databaseMetaData.getSchemas("JDBC_DB1", "%"); resultSet.next(); @@ -463,11 +474,19 @@ public void testGetTables() throws SQLException { resultSet = databaseMetaData.getTables(null, null, null, new String[] {"SYSTEM_TABLE"}); assertEquals(0, getSizeOfResultSet(resultSet)); + // Exclude SNOWFLAKE system database from DatabaseMetadata + ResultSet snowflakeResultSet = databaseMetaData.getTables("SNOWFLAKE", null, null, null); + int numSnowflakeTables = getSizeOfResultSet(snowflakeResultSet); + resultSet = databaseMetaData.getTables(null, null, null, null); - assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet)); + assertEquals( + getAllObjectCountInDBViaInforSchema(getAllTable), + getSizeOfResultSet(resultSet) - numSnowflakeTables); resultSet = databaseMetaData.getTables(null, null, null, new String[] {"VIEW", "SYSTEM_TABLE"}); - assertEquals(getAllObjectCountInDBViaInforSchema(getAllView), getSizeOfResultSet(resultSet)); + assertEquals( + getAllObjectCountInDBViaInforSchema(getAllView), + getSizeOfResultSet(resultSet) - numSnowflakeTables); resultSet = databaseMetaData.getTables(null, null, null, new String[] {"TABLE", "SYSTEM_TABLE"}); @@ -477,17 +496,23 @@ public void testGetTables() throws SQLException { resultSet = databaseMetaData.getTables( null, null, null, new String[] {"TABLE", "VIEW", "SYSTEM_TABLE"}); - assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet)); + assertEquals( + getAllObjectCountInDBViaInforSchema(getAllTable), + getSizeOfResultSet(resultSet) - numSnowflakeTables); resultSet = databaseMetaData.getTables(null, null, null, new String[] {"TABLE", "VIEW"}); - assertEquals(getAllObjectCountInDBViaInforSchema(getAllTable), getSizeOfResultSet(resultSet)); + assertEquals( + getAllObjectCountInDBViaInforSchema(getAllTable), + getSizeOfResultSet(resultSet) - numSnowflakeTables); resultSet = databaseMetaData.getTables(null, null, null, new String[] {"TABLE"}); assertEquals( getAllObjectCountInDBViaInforSchema(getAllBaseTable), getSizeOfResultSet(resultSet)); resultSet = databaseMetaData.getTables(null, null, null, new String[] {"VIEW"}); - assertEquals(getAllObjectCountInDBViaInforSchema(getAllView), getSizeOfResultSet(resultSet)); + assertEquals( + getAllObjectCountInDBViaInforSchema(getAllView), + getSizeOfResultSet(resultSet) - numSnowflakeTables); resultSet = databaseMetaData.getTables("JDBC_DB1", "JDBC_SCHEMA11", null, new String[] {"TABLE"});