harshitaajoshi commented on code in PR #17526:
URL: https://github.com/apache/iceberg/pull/17526#discussion_r3723934430
##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -168,15 +168,17 @@ private void atomicCreateTable(String tableName, String
sqlCommand, String reaso
connections.run(
conn -> {
DatabaseMetaData dbMeta = conn.getMetaData();
+ String catalog = JdbcUtil.metadataCatalog(conn);
+ String escape = dbMeta.getSearchStringEscape();
// check the existence of a table name
Predicate<String> tableTest =
name -> {
try (ResultSet result =
dbMeta.getTables(
- null /* catalog name */,
+ catalog,
null /* schemaPattern */,
Review Comment:
Good point that a null `schemaPattern` does not narrow to the current
schema. I looked into using `Connection#getSchema()` and I think it needs to be
a separate change, because catalogs and schemas are not symmetric here.
An unqualified name can never resolve across catalogs, so restricting the
lookup to `getCatalog()` matches how the SQL in this class resolves names.
Schemas do not work that way. PostgreSQL resolves an unqualified
`iceberg_tables` through the whole `search_path`, while `getSchema()` returns
only `current_schema()`. For a connection with `search_path = myapp, public`
and the catalog tables in `public`, scoping to `myapp` would make the lookup
miss a table the SQL resolves fine, and `atomicCreateTable` would then try to
create a duplicate. That would break setups that work today.
Doing this correctly means matching `search_path` resolution, which the
metadata API cannot express directly, and it needs testing against a real
PostgreSQL. Happy to open a follow-up issue for schema scoping and keep this PR
to the catalog and wildcard problems from #17300, which are both safe on their
own. Let me know if you would rather see it here.
--
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]