Closed cmadlener closed 1 week ago
@cmadlener: thanks for this one - have made an update, and it'll be supported in the upcoming 1.7.0
release.
Thank you, @alexander-beedie for the quick response and fix! Looking forward to using it!
I just had a chance to try the latest release. I have a follow-up question: Would it be feasible to recursively apply the shortcutting logic to SQLExpr::Nested
? Right now, if you slightly modify the WHERE
clause by wrapping it in parenthesis, you will get the same exception as before.
import polars as pl
df = pl.DataFrame({"null_column": [None, None]})
ctx = pl.SQLContext({"df": df}, eager=True)
result = ctx.execute("SELECT * FROM df WHERE (true)")
Another case (that may also be deemed practically not relevant) is if you have multiple trivial clauses, e.g. WHERE true AND 'a' = 'a'
.
Looking at the phrasing in #18571 it might have been deliberate to only cover the "top-level" case. It makes sense to me that we don't want to more or less parse the whole expression to figure out the shortcutting. It makes me wonder, though, if the root cause here lies somewhere deeper in parse_sql_expr
resp. SQLExprVisitor
and should be fixed there.
Checks
Reproducible example
Log output
Issue description
In practice, I'm not actually using
true
andfalse
as conditions, but statements like'a' = 'a'
(which are dynamically created). Everything works as expected if the empty columns have a string type.Expected behavior
I get the entire DataFrame when the
WHERE
clause evaluates totrue
, and an empty DataFrame when it evaluates tofalse
.Installed versions