Repository navigation
fix(profiler): emit valid Databricks SQL for unquoted identifiers (backport #31347) - #31373
Merged
Merged
Conversation
…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)
Contributor
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
Code Review ✅ ApprovedBackports Databricks SQL fixes for unquoted identifier quoting in struct children, modulo operator translation for named paramstyles, and improved server error reporting. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes:
Backport of #31347 (
6814fc252aa).Profiling a Databricks or Unity Catalog asset fails with
[PARSE_SYNTAX_ERROR] ... SQLSTATE: 42601on every column, because the generated SQL has unbalanced identifier quoting:DatabricksProfilerInterface.visit_columnre-quotes STRUCT children and assumed the compiler always emits backtick-quoted identifiers.DatabricksIdentifierPreparerdeclareslegal_characters = ^[A-Z0-9_]+$, so SQLAlchemy quotes an identifier only when it is mixed-case, reserved, or contains illegal characters — an all-lowercaseschema.table.columnarrives unquoted, still satisfies thedot_count > 1guard, and gets rejoined without its outer backticks. The fix returns early when the compiled reference carries no backticks.ModuloFnhad no Databricks compiler and fell through to the generic%%escape, which onlyformat/pyformatparamstyle drivers unescape;databricks-sql-connectorusesnamedparamstyle, so Spark received a literal%%. RegisteringDialects.Databrickson the existingMOD(...)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: DYNAMICwithsmartSampling), which still route throughget_sample_queryand emit the_rndsample CTE that forces three-part column references.Type of change: