Skip to content

SNOW-2360274: Fix schema query sql generation for structured types#3804

Merged
sfc-gh-jrose merged 7 commits into
mainfrom
jrose_snow_2360274_nested_structured_type_sql_generation_fix
Sep 25, 2025
Merged

SNOW-2360274: Fix schema query sql generation for structured types#3804
sfc-gh-jrose merged 7 commits into
mainfrom
jrose_snow_2360274_nested_structured_type_sql_generation_fix

Conversation

@sfc-gh-jrose

Copy link
Copy Markdown
Contributor
  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-2360274

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
    • If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: AST Support Guidelines
  3. Please describe how your code solves the related issue.

The sql generation for describe queries has an edge case that can cause invalid sql to be generated when using nested structured types. The schema_expression function does it's best to respect nullability when generating schema queries. Snowflake does not support nullability inside of structured types so this should not be needed for structured types. This fix short circuits the sql generation by replacing the recursive call with NULLs. I have not found any cases in which this would break, but to be extra sure it's not a BCR I am gating it behind a context variable. In order to use this bugfix you will have to set context. _enable_fix_2360274 to be True.

Comment thread CHANGELOG.md Outdated
@sfc-gh-jrose sfc-gh-jrose requested a review from a team September 24, 2025 21:22
Comment thread src/snowflake/snowpark/_internal/analyzer/datatype_mapper.py Outdated
Comment thread src/snowflake/snowpark/_internal/analyzer/datatype_mapper.py Outdated
Comment thread src/snowflake/snowpark/_internal/analyzer/datatype_mapper.py Outdated
Comment thread src/snowflake/snowpark/context.py
@sfc-gh-jrose sfc-gh-jrose merged commit f619911 into main Sep 25, 2025
28 checks passed
@sfc-gh-jrose sfc-gh-jrose deleted the jrose_snow_2360274_nested_structured_type_sql_generation_fix branch September 25, 2025 07:44
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants