nastra commented on code in PR #10124:
URL: https://github.com/apache/iceberg/pull/10124#discussion_r1565243207


##########
core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java:
##########
@@ -1020,4 +1062,36 @@ private void initLegacySchema(String jdbcUrl) throws 
SQLException {
           .execute();
     }
   }
+
+  private boolean catalogTablesExist(String jdbcUrl) throws SQLException {
+    SQLiteDataSource dataSource = new SQLiteDataSource();
+    dataSource.setUrl(jdbcUrl);
+
+    boolean catalogTableExists = false;
+    boolean namespacePropertiesTableExists = false;
+
+    try (Connection connection = dataSource.getConnection()) {
+      DatabaseMetaData metadata = connection.getMetaData();
+      if (tableExists(metadata, JdbcUtil.CATALOG_TABLE_VIEW_NAME)) {
+        catalogTableExists = true;
+      }
+      if (tableExists(metadata, JdbcUtil.NAMESPACE_PROPERTIES_TABLE_NAME)) {
+        namespacePropertiesTableExists = true;
+      }
+    }
+
+    return catalogTableExists && namespacePropertiesTableExists;
+  }
+
+  boolean tableExists(DatabaseMetaData metadata, String tableName) throws 
SQLException {
+    ResultSet resultSet = metadata.getTables(null, null, tableName, new 
String[] {"TABLE"});
+
+    while (resultSet.next()) {
+      if (resultSet.getString("TABLE_NAME").equals(tableName)) {

Review Comment:
   I would switch this around to 
`tableName.equals(resultSet.getString("TABLE_NAME"))` in case 
`resultSet.getString("TABLE_NAME")` returns `null` 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to