Skip to content

Division by a compound expression loses its parentheses on Snowflake and Databricks #439

Open

Description

@jat255

When a definition divides by a compound expression, the SQL for Snowflake and Databricks drops the parentheses around the divisor. The DuckDB SQL is correct.

Definition SQL for Snowflake and Databricks
amount / (ratio * 2) "amount" / "ratio" * 2
-(amount - 2) / (ratio + 1.0) -("amount" - 2) / "ratio" + 1.0

The first query runs and returns a wrong value, with no error. The second fails with Division by zero when ratio is 0, because the zero check tests ratio + 1.0 but the query divides by ratio.

Both packages have the same fault: _divide() and definition_sql_divide() render both operands at the lowest precedence, then join them with /. definition-warehouse-sql.json has no case with a compound divisor, so neither suite finds this without a live warehouse. Found by test_the_emitted_definition_sql_agrees_with_duckdb in #434.

Activity

  1. added
    bugSomething isn't working
    rAffects the R implementation
    pyAffects the Python implementation
    on Oct 21, 2026
  2. self-assigned this
    on Oct 21, 2026
  3. added 2 commits that reference this issue on Oct 22, 2026
    44d353a
    0485bd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpyAffects the Python implementationrAffects the R implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions