Skip to content

Conversation

@fivetran-kwoodbeck
Copy link
Collaborator

Adds support for transpiling Snowflake's NORMAL function to DuckDB using the Box-Muller transform.

See the Jira task for full testing to confirm distribution similarity between Snowflake and transpiled version.

Changes:

  • duckdb.py:
    • Add normal_sql() method to generate the transform. Uses templates and replace_placeholders due to unwieldily AST
    • Add NORMAL_TEMPLATE for Box-Muller formula: mean + stddev * sqrt(-2 * ln(u1)) * cos(2π * u2)
    • Add SEEDED_RANDOM_TEMPLATE for deterministic pseudo-random values

Behavior:
-- RANDOM() generator uses RANDOM()
-- Seeded generator uses HASH

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:feature/transpile-normal, sqlglot version: feature/transpile-normal)
  • baseline (main, sqlglot version: 28.5.1.dev54)

⚠️ Limited to dialects: snowflake, duckdb

By Dialect

dialect main sqlglot:feature/transpile-normal difference links
duckdb -> duckdb 4003/4003 passed (100.0%) 4003/4003 passed (100.0%) No change full result / delta
snowflake -> duckdb 626/1085 passed (57.7%) 626/1085 passed (57.7%) No change full result / delta
snowflake -> snowflake 981/1085 passed (90.4%) 981/1085 passed (90.4%) No change full result / delta

Overall

main: 6173 total, 5610 passed (pass rate: 90.9%), sqlglot version: 28.5.1.dev54

sqlglot:feature/transpile-normal: 6173 total, 5610 passed (pass rate: 90.9%), sqlglot version: feature/transpile-normal

Difference: No change

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