diff --git a/ibis/backends/clickhouse/compiler/core.py b/ibis/backends/clickhouse/compiler/core.py index cdfea0d8cf67..2b6590fcff66 100644 --- a/ibis/backends/clickhouse/compiler/core.py +++ b/ibis/backends/clickhouse/compiler/core.py @@ -29,6 +29,7 @@ from ibis.backends.clickhouse.compiler.values import translate_val from ibis.common.deferred import _ from ibis.expr.analysis import c, find_first_base_table, p, x, y +from ibis.expr.rewrites import rewrite_dropna, rewrite_fillna if TYPE_CHECKING: from collections.abc import Mapping @@ -122,6 +123,8 @@ def fn(node, _, **kwargs): | subtract_one_from_one_indexed_functions | add_one_to_nth_value_input | nullify_empty_string_results + | rewrite_fillna + | rewrite_dropna ) # apply translate rules in topological order node = op.map(fn)[op] diff --git a/ibis/backends/clickhouse/compiler/relations.py b/ibis/backends/clickhouse/compiler/relations.py index 7ea302f863b4..a4297c5e8ddf 100644 --- a/ibis/backends/clickhouse/compiler/relations.py +++ b/ibis/backends/clickhouse/compiler/relations.py @@ -7,7 +7,7 @@ import ibis.common.exceptions as com import ibis.expr.operations as ops -from ibis.backends.base.sqlglot import FALSE, NULL, STAR +from ibis.backends.base.sqlglot import STAR @functools.singledispatch @@ -200,33 +200,6 @@ def _distinct(op: ops.Distinct, *, table, **_): return sg.select(STAR).distinct().from_(table) -@translate_rel.register -def _dropna(op: ops.DropNa, *, table, how, subset, **_): - colnames = op.schema.names - alias = table.alias_or_name - - if subset is None: - columns = [sg.column(name, table=alias) for name in colnames] - else: - columns = subset - - if columns: - func = sg.and_ if how == "any" else sg.or_ - predicate = func(*(sg.not_(col.is_(NULL)) for col in columns)) - elif how == "all": - predicate = FALSE - else: - predicate = None - - if predicate is None: - return table - - try: - return table.where(predicate) - except AttributeError: - return sg.select(STAR).from_(table).where(predicate) - - @translate_rel.register def _sql_string_view(op: ops.SQLStringView, query: str, **_: Any): table = sg.table(op.name) diff --git a/ibis/backends/tests/test_generic.py b/ibis/backends/tests/test_generic.py index b5862e236e20..79c102a47c9a 100644 --- a/ibis/backends/tests/test_generic.py +++ b/ibis/backends/tests/test_generic.py @@ -425,7 +425,7 @@ def test_table_fillna_invalid(alltypes): ), ], ) -@pytest.mark.notimpl(["datafusion", "clickhouse"]) +@pytest.mark.notimpl(["datafusion"]) def test_table_fillna_mapping(backend, alltypes, replacements): table = alltypes.mutate( int_col=alltypes.int_col.nullif(1), @@ -440,7 +440,7 @@ def test_table_fillna_mapping(backend, alltypes, replacements): backend.assert_frame_equal(result, expected, check_dtype=False) -@pytest.mark.notimpl(["datafusion", "clickhouse", "druid", "oracle"]) +@pytest.mark.notimpl(["datafusion", "druid", "oracle"]) def test_table_fillna_scalar(backend, alltypes): table = alltypes.mutate( int_col=alltypes.int_col.nullif(1),