Repository navigation
fix(profiler): emit valid Databricks SQL for unquoted identifiers (backport #31347) - #31374
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)
❌ 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 ✅ ApprovedBackport fixing Databricks profiler SQL generation for unquoted identifiers and registering the Databricks modulo function compiler. 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 |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
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:
Adapted for this branch:
Dialects.Exasolis not registered on theMOD(...)group here, so only theDialects.Databricksline is added. Formatting re-run with this branch's black/isort/pycln toolchain rather than ruff.