Skip to content

feat(duckdb): Add tests for TO_CHAR#7635

Merged
georgesittas merged 1 commit into
mainfrom
RD-1069318-to-char-to-varchar
May 12, 2026
Merged

feat(duckdb): Add tests for TO_CHAR#7635
georgesittas merged 1 commit into
mainfrom
RD-1069318-to-char-to-varchar

Conversation

@fivetran-amrutabhimsenayachit
Copy link
Copy Markdown
Collaborator

https://fivetran.atlassian.net/browse/RD-1069318

Problem: TO_CHAR(numeric, 'format') in Snowflake uses Oracle-style numeric format patterns (e.g. '99999.99'). When transpiling to DuckDB, the format argument was silently dropped, producing CAST(x AS TEXT) without any indication of the loss.

Solution: Confirmed the current CAST(x AS TEXT) + @unsupported_args("format") warning in the base generator is already the correct fallback — DuckDB has no native Oracle numeric format function and a partial translator would produce silently wrong results for several patterns (B, S, MI, EEEE). Added 4 integration tests to the submodule documenting the exact transpilation behavior for all cases: numeric (no format), TO_VARCHAR alias, date format (working via STRFTIME), and numeric with Oracle format (known limitation).

@georgesittas georgesittas force-pushed the RD-1069318-to-char-to-varchar branch from d04321d to 2797047 Compare May 12, 2026 16:52
@georgesittas georgesittas merged commit 6ecd8bd into main May 12, 2026
8 checks passed
@georgesittas georgesittas deleted the RD-1069318-to-char-to-varchar branch May 12, 2026 16:54
@github-actions
Copy link
Copy Markdown
Contributor

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:RD-1069318-to-char-to-varchar, sqlglot version: RD-1069318-to-char-to-varchar)
  • baseline (sqlglot:cold-prql-test, sqlglot version: cold-prql-test)

By Dialect

dialect sqlglot:cold-prql-test sqlglot:RD-1069318-to-char-to-varchar transitions links
databricks -> databricks 1370/1370 passed (100.0%) 1370/1370 passed (100.0%) No change full result / delta
postgres -> postgres 6042/6042 passed (100.0%) 6042/6042 passed (100.0%) No change full result / delta
redshift -> redshift 7100/7101 passed (100.0%) 7101/7101 passed (100.0%) 1 fail -> pass full result / delta
snowflake -> snowflake 63027/63027 passed (100.0%) 63027/63027 passed (100.0%) No change full result / delta
bigquery -> bigquery 23497/23497 passed (100.0%) 23497/23497 passed (100.0%) No change full result / delta

Overall

sqlglot:cold-prql-test: 101037 total, 101036 passed (pass rate: 100.0%), sqlglot version: cold-prql-test

sqlglot:RD-1069318-to-char-to-varchar: 101037 total, 101037 passed (pass rate: 100.0%), sqlglot version: RD-1069318-to-char-to-varchar

Transitions:
1 fail -> pass

✅ 62 test(s) passed

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