Skip to content

feat: Replace information schema with describe calls#1415

Open
tejassp-db wants to merge 5 commits intomainfrom
replace-IS-with-describe-calls
Open

feat: Replace information schema with describe calls#1415
tejassp-db wants to merge 5 commits intomainfrom
replace-IS-with-describe-calls

Conversation

@tejassp-db
Copy link
Copy Markdown
Collaborator

@tejassp-db tejassp-db commented Apr 21, 2026

Description

Replace expensive information_schema queries with a single DESCRIBE TABLE EXTENDED ... AS JSON call for metadata fetching in _describe_relation methods. Gated behind DBRCapability.DESCRIBE_TABLE_EXTENDED_AS_JSON (DBR 17.3+), falls back to existing info_schema queries on older runtimes.

Changes:

  • IncrementalTableAPI._describe_relation: replaces 4 info_schema queries (PK, FK, non-null constraints, column masks) with AS JSON parsing
  • MaterializedViewAPI._describe_relation: replaces get_view_description (info_schema.views) with AS JSON parsing
  • ViewAPI._describe_relation: same as MV
  • New DatabricksDescribeJsonMetadata parser class with composite PK/FK support
  • New is_describe_as_json_supported() gating method (checks HMS, foreign table, capability)
  • New is_foreign_table property on DatabricksRelation
  • New describe_table_extended_as_json Jinja macro

Testing:

  • 56 unit tests: parser, processor roundtrip, diff validation, edge cases
  • Capability boundary tests (17.2 vs 17.3)
  • is_describe_as_json_supported unit tests (UC, HMS, foreign table, no capability)
  • Jinja macro SQL generation test
  • Functional tests validated on both code paths:
    • SQL warehouse (DBR 17.3+): all 14 constraint/mask tests passed via DESCRIBE AS JSON path
    • UC cluster (DBR 16.4 LTS): all 14 tests passed via information_schema fallback path

Checklist

  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt-databricks next" section.

PECOBLR-2546

Add alternate code path for metadata fetching in _describe_relation
methods using DESCRIBE TABLE EXTENDED AS JSON (DBR 17.3+).

Replaces 4 information_schema queries in IncrementalTableAPI and
get_view_description in MaterializedViewAPI/ViewAPI. Falls back
to legacy queries when capability is unavailable.

PECOBLR-2546
@tejassp-db tejassp-db self-assigned this Apr 21, 2026
@tejassp-db tejassp-db changed the title Replace information schema with describe calls feat: Replace information schema with describe calls Apr 21, 2026
@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  dbr_capabilities.py
  impl.py 414-417, 420-421, 1096-1105, 1147-1172, 1190-1208
  relation.py 123
Project Total  

This report was generated by python-coverage-comment-action

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