rdblue commented on a change in pull request #3275:
URL: https://github.com/apache/iceberg/pull/3275#discussion_r735998467



##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java
##########
@@ -359,20 +407,33 @@ public void close() {
   public boolean namespaceExists(Namespace namespace) {
     try {
       return connections.run(conn -> {
-        boolean exists = false;
+        boolean tableExists = false;
 
         try (PreparedStatement sql = 
conn.prepareStatement(JdbcUtil.GET_NAMESPACE_SQL)) {
           sql.setString(1, catalogName);
           sql.setString(2, JdbcUtil.namespaceToString(namespace) + "%");
           ResultSet rs = sql.executeQuery();
           if (rs.next()) {
-            exists = true;
+            tableExists = true;
+          }
+
+          rs.close();
+        }
+
+        boolean namespacePropertyExists = false;
+
+        try (PreparedStatement sql = 
conn.prepareStatement(JdbcUtil.GET_NAMESPACE_PROPERTIES_SQL)) {
+          sql.setString(1, catalogName);
+          sql.setString(2, JdbcUtil.namespaceToString(namespace) + "%");
+          ResultSet rs = sql.executeQuery();
+          if (rs.next()) {
+            namespacePropertyExists = true;
           }
 
           rs.close();
         }
 
-        return exists;
+        return (tableExists || namespacePropertyExists);

Review comment:
       Yeah, I'm just saying that if we know it exists because there's a table, 
we don't need to run the properties query. So we could short-circuit if 
`tableExists` is true and run the properties query if it is false to see if it 
exists via properties with no tables.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to