Skip to content

Fix IMPORT FOREIGN SCHEMA to pass catalog and schema to JDBC metadata…#55

Open
bgiesbrecht wants to merge 1 commit into
pgspider:mainfrom
bgiesbrecht:fix/import-foreign-schema-catalog-schema
Open

Fix IMPORT FOREIGN SCHEMA to pass catalog and schema to JDBC metadata…#55
bgiesbrecht wants to merge 1 commit into
pgspider:mainfrom
bgiesbrecht:fix/import-foreign-schema-catalog-schema

Conversation

@bgiesbrecht
Copy link
Copy Markdown

The existing implementation calls DatabaseMetaData.getTables() and getColumns() with null catalog and null schema, causing it to enumerate all catalogs. This fails on Databricks (and likely other cloud JDBC sources) where cross-catalog metadata access is restricted.

Changes:

  • Add 'catalog' server option so users can specify the remote catalog
  • Thread catalog (from server option) and schema (from the SQL statement's remote_schema) through the full call chain: jdbcImportForeignSchema -> jq_get_schema_info -> jq_get_table_names and jq_get_column_infos -> Java getTableNames/getColumnNames/ getColumnTypes/getPrimaryKey
  • Java methods now accept optional catalog and schema parameters and pass them to DatabaseMetaData.getTables/getColumns/getPrimaryKeys
  • Add support for LIMIT TO and EXCEPT table filtering
  • Generated CREATE FOREIGN TABLE statements now include table_name in OPTIONS and properly quote column names with quote_identifier()
  • Backward compatible: existing no-arg Java methods delegate to the new overloads with null defaults

Tested with Databricks OSS JDBC driver 3.3.1 against Unity Catalog.

… calls

The existing implementation calls DatabaseMetaData.getTables() and
getColumns() with null catalog and null schema, causing it to enumerate
all catalogs. This fails on Databricks (and likely other cloud JDBC
sources) where cross-catalog metadata access is restricted.

Changes:
- Add 'catalog' server option so users can specify the remote catalog
- Thread catalog (from server option) and schema (from the SQL
  statement's remote_schema) through the full call chain:
  jdbcImportForeignSchema -> jq_get_schema_info -> jq_get_table_names
  and jq_get_column_infos -> Java getTableNames/getColumnNames/
  getColumnTypes/getPrimaryKey
- Java methods now accept optional catalog and schema parameters and
  pass them to DatabaseMetaData.getTables/getColumns/getPrimaryKeys
- Add support for LIMIT TO and EXCEPT table filtering
- Generated CREATE FOREIGN TABLE statements now include table_name
  in OPTIONS and properly quote column names with quote_identifier()
- Backward compatible: existing no-arg Java methods delegate to the
  new overloads with null defaults

Tested with Databricks OSS JDBC driver 3.3.1 against Unity Catalog.
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.

1 participant