You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Division by a compound expression loses its parentheses on Snowflake and Databricks #439
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
fix: keep a division's operands grouped on Snowflake and Databricks
fix: keep a division's operands grouped on Snowflake and Databricks