Skip to content

Commit

Permalink
feat(duckdb): make sure any and all handle filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed Sep 8, 2023
1 parent 3576f4b commit 00c54b5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions ibis/backends/duckdb/compiler/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,26 @@ def _not(op, **kw):
return sg.expressions.Not(this=arg)


@translate_val.register(ops.Any)
def _any(op, **kw):
arg = translate_val(op.arg, **kw)
any_expr = sg.expressions.AnyValue(this=arg)
if op.where is not None:
where = sg.expressions.Where(this=translate_val(op.where, **kw))
return sg.expressions.Filter(this=any_expr, expression=where)
return any_expr


@translate_val.register(ops.All)
def _any(op, **kw):
arg = translate_val(op.arg, **kw)
all_expr = sg.func("bool_and", arg)
if op.where is not None:
where = sg.expressions.Where(this=translate_val(op.where, **kw))
return sg.expressions.Filter(this=all_expr, expression=where)
return all_expr


### Timey McTimeFace


Expand Down Expand Up @@ -537,8 +557,6 @@ def _levenshtein(op, **kw):
ops.Mean: "avg",
ops.Max: "max",
ops.Min: "min",
ops.Any: "any_value",
ops.All: "min",
ops.ArgMin: "arg_min",
ops.Mode: "mode",
ops.ArgMax: "arg_max",
Expand Down

0 comments on commit 00c54b5

Please sign in to comment.