harshitaajoshi commented on code in PR #17526:
URL: https://github.com/apache/iceberg/pull/17526#discussion_r3723938230


##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcUtil.java:
##########
@@ -530,6 +535,58 @@ static boolean isConstraintViolation(SQLException ex) {
         || (ex.getMessage() != null && ex.getMessage().contains("constraint 
failed"));
   }
 
+  /**
+   * Returns the catalog that {@link java.sql.DatabaseMetaData} lookups should 
be restricted to, or
+   * null to leave them unrestricted.
+   *
+   * <p>A null catalog does not restrict a lookup to the database the 
connection points at, so
+   * catalog tables in an unrelated database can be mistaken for this 
catalog's own. An empty
+   * catalog name is not used because it selects only objects that belong to 
no catalog.
+   *
+   * @param conn a connection to resolve the catalog of
+   */
+  static String metadataCatalog(Connection conn) {
+    try {
+      String catalog = conn.getCatalog();
+      return catalog == null || catalog.isEmpty() ? null : catalog;

Review Comment:
   You are right, thanks. `""` and `null` are different and I should not have 
collapsed them. Removed the empty check so the driver's answer is passed 
through unchanged.
   
   For what it is worth I checked, and neither SQLite nor Derby ever returns 
`""` from `getCatalog()`, so that branch was dead code on top of being wrong.



-- 
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