Skip to content

Commit

Permalink
refactor(flink): use FILTER syntax when counting
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and cpcloud committed Oct 9, 2023
1 parent 2cbca74 commit 815c12f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ibis/backends/flink/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@


def _count_star(translator: ExprTranslator, op: ops.Node) -> str:
# TODO(deepyaman): Use `FILTER` syntax; see note on `_filter` below.
if (where := op.where) is not None:
condition = f"CASE WHEN {translator.translate(where)} THEN 1 END"
condition = f" FILTER (WHERE {translator.translate(where)})"
else:
condition = "*"
condition = ""

return f"COUNT({condition})"
return f"COUNT(*){condition}"


def _date(translator: ExprTranslator, op: ops.Node) -> str:
Expand Down

0 comments on commit 815c12f

Please sign in to comment.