From eeabdee8dfc6c0d188480e12f3871a5e6cd937e5 Mon Sep 17 00:00:00 2001 From: Krzysztof Date: Wed, 15 Mar 2023 01:01:44 +0100 Subject: [PATCH] feat(snowflake): support binary variance reduction with filters --- ibis/backends/postgres/registry.py | 15 ++++++++++----- ibis/backends/tests/test_aggregation.py | 6 ------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ibis/backends/postgres/registry.py b/ibis/backends/postgres/registry.py index dcd72ee8c62d..ea2a42bd78c5 100644 --- a/ibis/backends/postgres/registry.py +++ b/ibis/backends/postgres/registry.py @@ -448,12 +448,17 @@ def variance_compiler(t, op): if (y_type := y.output_dtype).is_boolean(): y = ops.Cast(y, dt.Int32(nullable=y_type.nullable)) - result = func(t.translate(x), t.translate(y)) + if t._has_reduction_filter_syntax: + result = func(t.translate(x), t.translate(y)) - if (where := op.where) is not None: - return result.filter(t.translate(where)) - - return result + if (where := op.where) is not None: + return result.filter(t.translate(where)) + return result + else: + if (where := op.where) is not None: + x = ops.Where(where, x, None) + y = ops.Where(where, y, None) + return func(t.translate(x), t.translate(y)) return variance_compiler diff --git a/ibis/backends/tests/test_aggregation.py b/ibis/backends/tests/test_aggregation.py index b00990206f7f..8a13005fcd5f 100644 --- a/ibis/backends/tests/test_aggregation.py +++ b/ibis/backends/tests/test_aggregation.py @@ -722,12 +722,6 @@ def test_quantile( lambda t: t.yearID.isin([2009, 2015]), lambda t: t.yearID.isin([2009, 2015]), id='cond', - marks=[ - pytest.mark.broken( - ["snowflake"], - reason=("snowflake doesn't allow quoted columns in group_by"), - ), - ], ), ], )