Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC backend: infer catalog and schema if not specified #8131

Merged
merged 2 commits into from Feb 28, 2024

Conversation

adutra
Copy link
Contributor

@adutra adutra commented Feb 28, 2024

No description provided.

@Override
String catalog();
Optional<String> catalog();
Copy link
Contributor Author

@adutra adutra Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe defaulting to the empty string is wrong. According to the javadocs of java.sql.DatabaseMetaData#getTables:

catalog – a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search

So, using the empty string means that we are going to look for tables that do not belong to any catalog, which seems wrong. Same for schema.

Still according to the javadocs, it's imo better to pass null if the catalog is not known, the risk being that a table in a different catalog could exist with the same name as a Nessie table. But in this case, the schema check would fail anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: the PG driver does not seem to comply with the javadocs: looking at the implementation of getTables, catalog is not used at all, and schema is ignored when it's null or empty.

So the previous code was probably correct for PG, but maybe not correct for other drivers.

@adutra adutra merged commit 16622f2 into projectnessie:main Feb 28, 2024
17 checks passed
@adutra adutra deleted the jdbc-config-enhancement branch February 28, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants