rdblue commented on a change in pull request #3275:
URL: https://github.com/apache/iceberg/pull/3275#discussion_r735980431
##########
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:
What about testing `tableExists` early to avoid needing to do a second
database query?
--
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]