Skip to content

feat(snowflake): transpile Snowflake IDENTIFIER function to DuckDB#7723

Merged
georgesittas merged 7 commits into
mainfrom
transpile/snowflake-identifier-function
Jun 19, 2026
Merged

feat(snowflake): transpile Snowflake IDENTIFIER function to DuckDB#7723
georgesittas merged 7 commits into
mainfrom
transpile/snowflake-identifier-function

Conversation

@fivetran-kwoodbeck

Copy link
Copy Markdown
Collaborator

Snowflake's IDENTIFIER(), which resolves a string to a runtime identifier, previously fell through to exp.Anonymous. This folds it into a typed exp.Identifier node (flagged with identifier_func=True) so the Snowflake generator reconstructs IDENTIFIER('name') and the DuckDB generator emits a native identifier. It includes splitting dot-qualified names like IDENTIFIER('t1.col') into a proper exp.Dot chain.

Non-foldable args like IDENTIFIER($var) remain as exp.Anonymous so they round-trip correctly.

Behavior

Snowflake input DuckDB output
IDENTIFIER('col') col
IDENTIFIER('t1.col') t1.col
IDENTIFIER('"Col"') "Col"
IDENTIFIER($var) IDENTIFIER($var)

@github-actions

This comment was marked as outdated.

@georgesittas georgesittas self-assigned this Jun 10, 2026

@georgesittas georgesittas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @fivetran-kwoodbeck, I don't think this is the right approach. We should parse the IDENTIFIER(...) argument, and only when it's a string, otherwise you risk breaking case-sensitive identifiers. I wonder if we should just use to_column and to_table directly and produce semantically equivalent SQL without the IDENTIFIER call.

Falling back to an Anonymous node in other cases is good. I would also have a try-except block to make sure we gracefully handle parse failures and fall back to the IDENTIFIER(...) syntax.

Check this out too: https://github.com/fivetran/sqlglot-integration-tests/pull/452#pullrequestreview-4467142494.

Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/parsers/snowflake.py
@fivetran-kwoodbeck fivetran-kwoodbeck force-pushed the transpile/snowflake-identifier-function branch from 12b5a1f to d97ad27 Compare June 11, 2026 04:20
Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/generators/snowflake.py Outdated
@fivetran-kwoodbeck fivetran-kwoodbeck force-pushed the transpile/snowflake-identifier-function branch from d97ad27 to 12e2d66 Compare June 12, 2026 18:28
Comment thread sqlglot/expressions/core.py Outdated
Comment thread sqlglot/expressions/core.py Outdated
Comment thread sqlglot/generator.py Outdated
Comment thread sqlglot/generator.py
Comment thread sqlglot/parsers/snowflake.py
Comment thread sqlglot/parsers/snowflake.py Outdated
Comment thread sqlglot/expressions/core.py Outdated

@georgesittas georgesittas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-kwoodbeck this looks better. One comment is pending and I think the submodule pointer needs to be updated as well.

@fivetran-kwoodbeck fivetran-kwoodbeck force-pushed the transpile/snowflake-identifier-function branch from bdeb4b5 to 161022e Compare June 18, 2026 19:19
@fivetran-kwoodbeck

Copy link
Copy Markdown
Collaborator Author

@fivetran-kwoodbeck this looks better. One comment is pending and I think the submodule pointer needs to be updated as well.

@georgesittas I replied and updated the submodule

@georgesittas georgesittas merged commit 78c5cf9 into main Jun 19, 2026
8 checks passed
@georgesittas georgesittas deleted the transpile/snowflake-identifier-function branch June 19, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants