Skip to content

fix(profiler): emit valid Databricks SQL for unquoted identifiers (backport #31347) - #31373

Merged
IceS2 merged 1 commit into
2.0from
backport/31347-2.0
Aug 12, 2026
Merged

IceS2 merged 1 commit into
2.0from
backport/31347-2.0

Conversation

@IceS2

@IceS2 IceS2 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes:

Backport of #31347 (6814fc252aa).

Profiling a Databricks or Unity Catalog asset fails with [PARSE_SYNTAX_ERROR] ... SQLSTATE: 42601 on every column, because the generated SQL has unbalanced identifier quoting:

-- generated
SELECT my_schema`.`my_table`.`my_col FROM my_schema.my_table
-- expected
SELECT my_schema.my_table.my_col FROM my_schema.my_table

DatabricksProfilerInterface.visit_column re-quotes STRUCT children and assumed the compiler always emits backtick-quoted identifiers. DatabricksIdentifierPreparer declares legal_characters = ^[A-Z0-9_]+$, so SQLAlchemy quotes an identifier only when it is mixed-case, reserved, or contains illegal characters — an all-lowercase schema.table.column arrives unquoted, still satisfies the dot_count > 1 guard, and gets rejoined without its outer backticks. The fix returns early when the compiled reference carries no backticks.

ModuloFn had no Databricks compiler and fell through to the generic %% escape, which only format/pyformat paramstyle drivers unescape; databricks-sql-connector uses named paramstyle, so Spark received a literal %%. Registering Dialects.Databricks on the existing MOD(...) group fixes it.

The progress and operation-metrics mixins now report a truncated server response body instead of only str(exc).

This needs no opt-in — it reproduces on the stock profiler defaults (randomizedSample: false, profileSampleConfig: DYNAMIC with smartSampling), which still route through get_sample_query and emit the _rnd sample CTE that forces three-part column references.

Type of change:

  • Bug fix

…1347)

* fix(profiler): emit valid Databricks SQL for unquoted identifiers

The Databricks compiler override that re-quotes STRUCT children assumed the
compiler always emits backtick-quoted identifiers. Databricks only quotes an
identifier when it needs it, so an all-lowercase schema.table.column arrives
unquoted, the struct heuristic fires on it and rejoins the parts without the
outer backticks, producing an unbalanced reference and a PARSE_SYNTAX_ERROR
on every column metric.

ModuloFn had no Databricks compiler and fell through to the generic `%%`
escape, which only pyformat/format paramstyle drivers unescape. The Databricks
driver uses named paramstyle, so Spark received a literal `%%`.

* fix(ingestion): log the server response on progress endpoint failures

The progress and metrics mixins logged only str(exc), so an HTTP failure
reduced to "400 Client Error: Bad Request for url: ..." with the server's
reason discarded. Report a truncated response body alongside it.

(cherry picked from commit 6814fc2)
@IceS2
IceS2 requested a review from a team as a code owner August 12, 2026 06:18
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added the safe to test Add this label to run secure Github workflows on PRs label Aug 12, 2026
@gitar-bot

gitar-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Backports Databricks SQL fixes for unquoted identifier quoting in struct children, modulo operator translation for named paramstyles, and improved server error reporting. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@IceS2
IceS2 merged commit 49ef1c2 into 2.0 Aug 12, 2026
88 of 138 checks passed
@IceS2
IceS2 deleted the backport/31347-2.0 branch August 12, 2026 06:35

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant