3 weeks ago
Hi Databricks Support Team,
We are evaluating whether dbt can execute successfully without access to system.information_schema in our environment, due to metadata access restrictions.
Our current setup uses:
During our POC, we observed that enabling this flag eliminates certain system.information_schema queries related to column masks and other relation metadata for existing incremental models. These queries are replaced by DESCRIBE TABLE EXTENDED ... AS JSON.
However, our logs show that dbt continues to query system.information_schema.tables for relation discovery across the dbt commands we tested, including model runs, seeds, tests, source freshness, and documentation generation.
When access to system.information_schema is restricted, these operations fail during relation discovery. Our custom drop macro was the exception in our tests.
Could you please clarify the following?
We would appreciate confirmation of the expected behavior for the versions listed above and any recommended configuration or workaround.
Thank you for your help.
3 weeks ago
Hi @Aju_Antony
Interesting question!!!
Short answer: no flag removes it. In dbt-databricks 1.12.x, relation discovery for Unity Catalog is hardcoded to system.information_schema.tables (the get_uc_tables macro), and use_describe_as_json_for_relation_metadata only swaps out the per-relation metadata lookups (masks, constraints etc.) for DESCRIBE TABLE EXTENDED ... AS JSON. So what you observed is the intended behavior. The supported way around it is to override the macro in your own project and point it at the catalog-level information_schema instead.
Where system.information_schema is still used in 1.12.5 (dbt/include/databricks/macros/adapters/):
- metadata.sql -> get_uc_tables_sql (relation discovery, every command)
- metadata.sql -> get_relation_last_modified_sql (source freshness without a loaded_at_field)
- catalog.sql -> databricks__get_catalog_tables_sql / databricks__get_catalog_columns_sql (dbt docs generate)
- tags.sql / column_tags.sql -> only if you use databricks_tags
Override for relation discovery - drop this in macros/get_uc_tables.sql in your dbt project (root-project macros take precedence over the adapter's):
{% macro get_uc_tables_sql(relation) %}
SELECT
table_name,
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), 'table', lower(table_type)) AS table_type,
lower(data_source_format) AS file_format,
table_owner,
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), lower(table_type), NULL) AS databricks_table_type
FROM {{ relation.database|lower }}.information_schema.tables
WHERE table_schema = '{{ relation.schema|lower }}'
{%- if relation.identifier %}
AND table_name = '{{ relation.identifier|lower }}'
{% endif %}
{% endmacro %}
It's the adapter's own query with only the FROM changed - <catalog>.information_schema.tables has the same columns and only needs USE CATALOG on your own catalog. Do the same FROM swap for the two catalog.sql macros if you need docs generate, and set loaded_at_field on sources so freshness doesn't go through get_relation_last_modified. Re-check these overrides when you upgrade the adapter, since you now own that SQL.
On least privilege: both system.information_schema and the per-catalog information_schema only return rows for objects the querying principal already has privileges on, so allowing the dbt principal to read it doesn't expose other tenants' table names. If your restriction is about visibility rather than a hard policy, that's usually the simpler fix.
Docs: https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-information-schema
3 weeks ago
Hi @Aju_Antony, were you able to try the get_uc_tables_sql override in your POC? Quick way to confirm it works: run dbt run with --debug and check that no query in the log references system.information_schema.
If that unblocked you, please click Accept as Solution so others with the same restriction can find it. If something else still hits system.information_schema, share the macro name from the debug log and I'll point you to the override for it.
2 weeks ago
Hi, your observations match how the adapter works:
1. Can you remove all system.information_schema queries? Not today. There's no flag or setting that does it. For Unity Catalog relations, dbt-databricks always lists relations by querying system.information_schema.tables. Source freshness on Unity Catalog also reads last_altered from it, and docs generation uses it for catalog metadata. Only hive_metastore relations use SHOW TABLES / SHOW VIEWS instead.
2. Is use_describe_as_json_for_relation_metadata meant to be partial? Yes. It only replaces the detailed per-relation metadata queries: constraints, column masks, row filters and view definitions. Relation discovery isn't covered by it. It also falls back to information_schema per relation when the relation isn't in Unity Catalog, is a foreign table, or the compute isn't a SQL warehouse or DBR 17.3+.
3. Alternatives
There's an open GitHub issue asking for a way to avoid the system catalog (#838). Adding your use case there is the best way to push it.
For source freshness, set loaded_at_field on your sources. dbt then queries max(<column>) on the source table instead of using information_schema.
You could override the get_uc_tables_sql macro in your project, but that's unsupported. You'd lose table type, format and owner information unless you rebuild it some other way, and future adapter upgrades may break it. I wouldn't recommend it for production.
4. Least privilege in a multi-tenant setup The good news: system.information_schema filters rows by privilege. Each principal only sees metadata for objects it already has access to in Unity Catalog. So giving a tenant's dbt service principal access doesn't expose other tenants' tables. A minimal setup per tenant:
USE CATALOG on system, and USE SCHEMA on system.information_schema only. Don't grant access to other system schemas like billing or access.
USE CATALOG, USE SCHEMA, CREATE TABLE and MODIFY on the tenant's own target catalog or schema.
SELECT on the tenant's source tables only.
That way the principal can only "see" what it's already allowed to touch, which is usually what the metadata restriction is meant to achieve.
Docs:
2 weeks ago
I spent some time and ran a reproducible validation of this behaviour using dbt-core 1.12.3 and dbt-databricks 1.12.5 on Databricks, both locally against a serverless SQL warehouse and through pinned serverless dbt job tasks.
The results confirm that enabling use_describe_as_json_for_relation_metadata does not eliminate all system.information_schema queries. It removed the observed column-mask lookup during an incremental rerun, but relation discovery continued querying system.information_schema.tables.
In this version, overriding only get_uc_tables_sql in the root dbt project was not sufficient.
The replacement SQL worked when the project macro was called directly, but normal dbt commands continued using the adapter's original discovery SQL.
The working approach required overriding both:
With both overrides in place, normal adapter-initiated relation discovery used the catalog-local information schema.
I also validated this with a minimal two-macro configuration, which successfully executed dbt seed, initial and incremental model runs, and dbt tests.
Depending on the dbt operations used, additional metadata paths may need attention:
The required overrides depend on which metadata operations your project exercises.
Have validated the behaviour across multiple configurations, starting with the stock adapter, then enabling the JSON metadata flag, applying the SQL helper override, and finally testing the expanded project-level overrides.
The tests covered relation discovery, seed loading, initial and incremental model runs, dbt tests, source freshness, documentation generation and relevant metadata retrieval paths.
A few observations from the investigation:
Have also compared metadata returned through catalog-local and system-level information schemas. Table, column and view metadata matched for the tested objects.
These observations were reproduced using both local dbt execution against a serverless SQL warehouse and Databricks serverless dbt job tasks, with additional metadata diagnostics performed locally.
The results demonstrate that the workaround is technically viable for the tested adapter version and operations.
This establishes a workable project-level metadata redirection technique for the tested dbt-databricks version, not an universal solution.
Although have tested with a dedicated non-admin OAuth service principal, it could still query both metadata namespaces. So, could not reproduce the restricted-access condition.
Therefore, the workaround should be validated using the actual restricted principal before adopting it in production. The results apply to the tested dbt-databricks version and execution paths.
The key takeaway is that the SQL helper override alone was not enough in 1.12.5, the corresponding discovery wrapper was necessary for normal dbt command execution in our environment.