Closed fwojciec closed 2 weeks ago
Hi - thanks for opening this. Two things:
Our type annotations aren't great. Ibis code is pretty dynamic, generally you can trust the output of the method/function/whatever to be properly typed, but the types of arguments are likely stricter than things that are actually supported. In this case here filter
is annotated to take a BooleanValue
(which will accept a BooleanScalar
or BooleanColumn
), but it also will work with a standard bool
(ibis
will automatically coerce to a BooleanScalar
). Going through the APIs to improve the accuracy of the type annotations and add tests to ensure they're accurate is a large project and not one we're prioritizing at the moment. Right now I recommend either submitting PRs to fix annotations for bugs that you run into, or (better, more feasible suggestion) just turn off typing for ibis
.
In your specific case this is also a case of user error. The .equals
method on an expression checks for expression-level equality (whether the left and right side are identical expressions). t.filter(t.a == 0)
is what you want here.
Thanks for the feedback - it all makes sense. I'm happy to close this as this is not really a bug, and I see if I can come up with a PR that addresses the specific issue here.
What happened?
Here is a repo with the reproduction of the issue on the screenshot: https://github.com/fwojciec/ibis-types-test
Legitimate uses of the
filter
method result in type errors reported bypyright
andpylance
. This is because thefilter
method expects the predicates to beir.BooleanValue | Sequence[ir.BooleanValue] | IfAnyAll
and the actual type of the predicates in the above examples is just a plain ol'bool
.Interestingly, the
equals
method provided by Ibis returns bbool
for its result, which seems like an inconsistency.I appreciate that static typing is not a priority for the project, so I'm happy to make a PR to try and fix any typing issues I come across, but I wanted to get some guidance first on how these types of issues should be addressed - in this case, is the solution basically adding
bool
as a type that's accepted by thefilter
method in addition to the internal Ibis types mentioned above? Or maybe this is just something that can be worked around by somehow casting the bool predicate into an instance ofBooleanValue
? Are there any documents/references I should look up to understand how static typing is supposed to work in Ibis?What version of ibis are you using?
ibis-framework[duckdb]>=9.0.0
specifically - on 9.0.0 right nowWhat backend(s) are you using, if any?
DuckDB
Relevant log output
No response
Code of Conduct