Skip to content

Commit

Permalink
chore(clickhouse): use anonymous function for clickhouse countif due …
Browse files Browse the repository at this point in the history
…to invalid sqlglot rewrite
  • Loading branch information
cpcloud committed Jan 8, 2024
1 parent 16904dc commit c736e92
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ibis/backends/clickhouse/compiler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,17 @@ def _array_slice_op(op, *, arg, start, stop, **_):
return F.arraySlice(arg, start_correct)


@translate_val.register(ops.Count)
def _count(op, *, arg, where, **_):
if where is not None:
return sg.exp.Anonymous(this="countIf", expressions=[arg, where])
return sg.exp.Count(this=arg)


@translate_val.register(ops.CountStar)
def _count_star(op, *, where, **_):
if where is not None:
return F.countIf(where)
return sg.exp.Anonymous(this="countIf", expressions=[where])
return sg.exp.Count(this=STAR)


Expand Down Expand Up @@ -744,7 +751,6 @@ def formatter(op, *, left, right, **_):
ops.ArgMin: "argMin",
ops.ArgMax: "argMax",
ops.ArrayCollect: "groupArray",
ops.Count: "count",
ops.CountDistinct: "uniq",
ops.First: "any",
ops.Last: "anyLast",
Expand Down

0 comments on commit c736e92

Please sign in to comment.