trino icon indicating copy to clipboard operation
trino copied to clipboard

Add JDBC connection current catalog fallback parameter

Open polomek opened this issue 11 months ago • 9 comments

Description

This commit introduces fallback (disabled by default), which will try to use catalog value passed through JDBC connection when fetching Trino metadata like: getTables, getColumns, getSchemas with catalog set to null.

Additional context and related issues

  • https://github.com/trinodb/trino/issues/16361
  • https://github.com/trinodb/trino/issues/1173

Release notes

( ) This is not user-visible or is docs only, and no release notes are required. ( ) Release notes are required. Please propose a release note for me. (x) Release notes are required, with the following suggested text: "Use connection current catalog fallback (disabled by default)"

polomek avatar Feb 28 '24 17:02 polomek

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] avatar Feb 28 '24 17:02 cla-bot[bot]

also re: commit message, consider this suggestion (i.e. describe why the change is being made and what the change is).

Add JDBC property to use current catalog in metadata if none provided

Some BI tools don't pass a `catalog` when calling the `DatabaseMetaData`
`getTables`, `getColumns` and `getSchemas` methods. This makes the JDBC
driver search across all catalogs which can be expensive.

This commit introduces a new boolean connection property
`assumeNullCatalogMeansCurrentCatalog` (disabled by default) to be used
with such BI tools. If enabled the driver will try to use current
`catalog` of the JDBC connection when fetching Trino metadata like
`getTables`, `getColumns`, `getSchemas` if the `catalog` argument to
those methods is passed as `null`.

hashhar avatar Feb 29 '24 06:02 hashhar

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

cla-bot[bot] avatar Feb 29 '24 09:02 cla-bot[bot]

@cla-bot check

kokosing avatar Mar 05 '24 10:03 kokosing

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Mar 05 '24 10:03 cla-bot[bot]

This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua

github-actions[bot] avatar Apr 10 '24 17:04 github-actions[bot]

Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time.

github-actions[bot] avatar May 02 '24 17:05 github-actions[bot]

This is something we want to merge, but we struggle to reproduce the problem it is fixing.

kokosing avatar May 02 '24 18:05 kokosing

struggle to reproduce

should be easy with a mock connector

findepi avatar May 10 '24 21:05 findepi

rebased on master + cleaned up the test a bit

hashhar avatar Jun 05 '24 11:06 hashhar

~actually maybe instead of assumeNullCatalogMeansCurrent it can just be nullCatalogMeansCurrent (specially because MySQL driver has nullDatabaseMeansCurrent (with nullCatalogMeansCurrent being an alias).~

Ignore this, we already have assumeLiteralUnderscoreInMetadataCallsForNonConformingClients, so this name is for internal consistency.

hashhar avatar Jun 06 '24 21:06 hashhar

We can document but it's something for exceptional cases (e.g. BI tools that misuse the DatabaseMetaData APIs, similar to assumeLiteralUnderscoreInMetadataCallsForNonConformingClients).

Doesn't affect either the CLI/JDBC unless enabled. Other clients don't need this since this is added for BI tools which misuse APIs and they use the JDBC driver only.

hashhar avatar Jun 06 '24 21:06 hashhar

Lets leave it as an internal, experts-only thing for now then, and keep an eye out if this problems comes up again.

mosabua avatar Jun 06 '24 21:06 mosabua

Thank you @polomek and @hashhar !

kokosing avatar Jun 11 '24 16:06 kokosing