New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(python): extend filter
capabilities with new support for *args
predicates, **kwargs
constraints, and chained boolean masks
#11740
feat(python): extend filter
capabilities with new support for *args
predicates, **kwargs
constraints, and chained boolean masks
#11740
Conversation
β¦s` predicates, `**kwargs` constraints, and chained boolean masks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this feature will be a nice quality-of-life upgrade to an often-used method!
I wonder if we can't just use parse_as_list_of_expressions
here? There seems to be a lot of duplicated parsing logic here.
Co-authored-by: Stijn de Gooijer <stijn@degooijer.io>
Co-authored-by: Stijn de Gooijer <stijn@degooijer.io>
We can't hand off to that completely, as the boolean masks need to be identified separately (update: it can be used to unify parsing of a single-list passed to *predicates without splatting though, so I smoothed that outπ). |
ace63f6
to
f24d4ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, Alex!
Closes #11642, supersedes #11674.
Ended up going a little deeper down the rabbit hole so moved it into my own branch to finish off as I was having issues rebasing / force-pushing to a branch I don't own (some sort of credentials/token issue? π€·); kudos to @mcrumiller for getting things started with the initial implementation!
Miscellaneous
predicate
keyword, so only warns on old-style usage.New Features
Adds support for:
*predicates
(one or more predicates as positional arguments).**constraints
(col == value
matches as keyword arguments).Examples
More than one predicate, now we have a positional args option.
Implicitly combines predicates with
all_horizontal
:Splat predicates assembled elsewhere straight into filter without having to combine them yourself:
Constrain rows using
**kwargs
format (essentially the same API that we offer inwith_columns
):Mix and match the two formats freely:
Easily filter against a Pydantic/FastAPI
Model
object:Chain boolean masks (previously only allowed one per
filter
invocation):