Skip to content

fix: handle grant column names case-insensitively - #1650

Open
TangoEnSkai wants to merge 4 commits into
databricks:mainfrom
TangoEnSkai:fix/grant-column-case-782
Open

fix: handle grant column names case-insensitively#1650
TangoEnSkai wants to merge 4 commits into
databricks:mainfrom
TangoEnSkai:fix/grant-column-case-782

Conversation

@TangoEnSkai

Copy link
Copy Markdown
Contributor

Resolves #782

Description

Databricks SHOW GRANTS results can expose the documented principal, actionType, and objectType columns with different casing depending on the execution environment. The inherited dbt-spark implementation indexes only Principal, ActionType, and ObjectType, which raises a KeyError when a connector returns lowercase names.

Override grant standardization in the Databricks adapter and resolve the three required columns case-insensitively. Grant filtering and grouping behavior is unchanged.

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.
  • [Optional] I have run the dbt-databricks-pr-ready project skill for this PR and addressed its merge-readiness feedback

Test plan

  • .venv/bin/pytest tests/unit/test_adapter.py::TestDatabricksAdapter::test_standardize_grants_dict_ignores_column_name_case -q (3 passed)
  • .venv/bin/pytest tests/unit/test_adapter.py -q (99 passed, 2 skipped)
  • .venv/bin/pre-commit run --files dbt/adapters/databricks/impl.py tests/unit/test_adapter.py

Signed-off-by: TangoEnSkai <21152231+TangoEnSkai@users.noreply.github.com>
Signed-off-by: TangoEnSkai <21152231+TangoEnSkai@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  dbt/adapters/databricks
  impl.py
Project Total  

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

Exercise SHOW GRANTS through apply_grants without extra test users so the live grant path is covered on Unity Catalog.
@sd-db

sd-db commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Overall change looks good and I added a functional test as well, but I was unable to recreate the bug in SQL Warehouse. I see that the columns are exposed as Camel Case and match the current implementation in dbt-spark. Can you tell which environment you are seeing the bug in ? Also I see now the original issue had the same comment as well on repro

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.

[Bug] Crash when dbt runs show grants statement due to column name capitalization mismatch

2 participants