Skip to content

feat(duckdb): Add transpilation support for positoinal column refs over values#7752

Closed
fivetran-amrutabhimsenayachit wants to merge 1 commit into
mainfrom
RD-1205932-transpile-bug-positional-column-ref-over-values
Closed

feat(duckdb): Add transpilation support for positoinal column refs over values#7752
fivetran-amrutabhimsenayachit wants to merge 1 commit into
mainfrom
RD-1205932-transpile-bug-positional-column-ref-over-values

Conversation

@fivetran-amrutabhimsenayachit

@fivetran-amrutabhimsenayachit fivetran-amrutabhimsenayachit commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Issue: Snowflake uses $N to reference the Nth column of a VALUES clause (e.g. v1.$2). DuckDB also uses $N but for prepared-statement parameters — so the transpiled SQL would fail at runtime in DuckDB.

Fix: Added column_sql to DuckDB's generator. When it sees a $N column reference whose table alias points to a VALUES source in the same query, it rewrites it to DuckDB's native column name format (col0, col1, ...) — so v1.$2 becomes v1.col1.

@fivetran-amrutabhimsenayachit fivetran-amrutabhimsenayachit force-pushed the RD-1205932-transpile-bug-positional-column-ref-over-values branch from 6bc6c2d to be9961d Compare June 15, 2026 18:58
@github-actions

Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

✅ All tests passed

Comparing:

  • this branch (sqlglot:RD-1205932-transpile-bug-positional-column-ref-over-values @ sqlglot 4c1f7bf)
  • baseline (main @ sqlglot 87b1da8)

Overall

main: 192441 total, 153536 passed (pass rate: 79.8%)

sqlglot:RD-1205932-transpile-bug-positional-column-ref-over-values: 186070 total, 148214 passed (pass rate: 79.7%)

Transitions:
No change

Dialect pair changes: 0 previous results not found, 2 current results not found

✅ All tests passed

@georgesittas

Copy link
Copy Markdown
Collaborator

Discussed in Slack/Jira: this is a more general issue with positional column refs which is not easy to transpile to DuckDB without invasive changes with considerable overhead.

Closing for now to avoid the complexity overhead in hot methods such as column_sql.

@georgesittas georgesittas deleted the RD-1205932-transpile-bug-positional-column-ref-over-values branch June 16, 2026 06:13
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