Repository navigation
fix: quote struct field names that need it in column types - #1710
Open
maharanay22 wants to merge 1 commit into
Open
maharanay22 wants to merge 1 commit into
maharanay22 wants to merge 1 commit into
Conversation
maharanay22
requested review from
jprakash-db,
saishreeeee and
sd-db
as code owners
October 8, 2026 22:35
`DatabricksColumn._parse_type_from_json` wrote struct field names from DESCRIBE ... AS JSON without quoting, so a field like `first name` or `order-id` produced `struct<first name:string,order-id:bigint>` and the materialization V2 CREATE or the on_schema_change ADD COLUMNS failed with PARSE_SYNTAX_ERROR. Quote a field name only when Spark's quoteIfNeeded would, backticking it and doubling embedded backticks, so type strings for ordinary names do not change. Nested structs inside arrays and maps are covered by the existing recursion. Signed-off-by: Maha Rana Yadavalli <271375718+maharanay22@users.noreply.github.com>
maharanay22
force-pushed
the
fix-struct-field-name-quoting
branch
from
October 8, 2026 22:35
f11093c to
8bb4f5a
Compare
This branch has not been 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.
No existing issue (I searched open and closed issues and PRs; #1070 is a different struct problem caused by truncated types).
Description
DatabricksColumn._parse_type_from_jsonbuilds struct types fromDESCRIBE ... AS JSONwithout quoting field names, so a field likefirst nameororder-idproducesstruct<first name:string,order-id:bigint>. That is invalid DDL, so the materialization V2CREATEandon_schema_changeADD COLUMNSfail withPARSE_SYNTAX_ERRORfor tables with JSON-style field names.Field names are now quoted only when Spark's
QuotingUtils.quoteIfNeededwould quote them: names matching[A-Za-z_][A-Za-z0-9_]*stay bare, and anything else is wrapped in backticks with embedded backticks doubled. Type strings for ordinary field names are unchanged (see #1148 for why that matters). Nested structs inside arrays and maps are handled by the existing recursion.New parametrized tests cover plain names (unchanged), space, hyphen, dot, colon, an embedded backtick, a leading digit, and a struct nested in an array and a map. 7 of the 8 fail on
main(the plain-name case passes by design) and all pass with this change.Checklist
CHANGELOG.mdand added information about my change to the "dbt-databricks next" section.dbt-databricks-pr-readyproject skill for this PR and addressed its merge-readiness feedback