feat(api): support more types in where
arg to reductions
#9246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All reductions in ibis take an optional columnar
where
argument - if present, this is used to filter the input before performing the reduction.Previously we accepted only actual
Value
inputs here, or deferred expressions. This means that the following would work:But not string inputs (would reference columns in the parent table by name), or callables (the lambda form of a deferred expression). Instead, all other inputs were coerced to a boolean (meaning
t.a.min(where="bool_col")
was surprisingly the same ast.a.min(where=True)
, but nott.a.min(where=_.bool_col)
).This PR:
where
args to column reductions to include direct values (t.bool_col
), deferred expressions (_.bool_col
), callables (lambda t: t.bool_col
), or string column names ("bool_col"
). All other inputs are coerced to a literal.t.count()
ort.nunique()
). In this case we just make use of the existingbind
functionality.where
arg is being properly handled in all reductions. In several cases it wasn't.This is a precursor leading to #9170, where we want to add additional args to some columnar reductions that bind to the parent table.