Conversation
JSON has no inf/nan, so polars serializes a Float32/Float64 literal of
inf, -inf or nan as null. The pushdown turned that into the SQL text
None, which DuckDB binds as a column name, so a lazy filter such as
pl.col('x') < float('inf') failed the whole collect() with
'Referenced column "None" not found'.
Treat a null float value as not pushable so polars applies the filter.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
JSON has no
inf/nan, so polars serializes aFloat32/Float64literal ofinf,-infornanasnull:{"BinaryExpr":{"left":{"Column":"a"},"op":"Lt","right":{"Literal":{"Scalar":{"Float64":null}}}}}The polars lazy-frame pushdown then returns
str(value[dtype]), which is the SQL textNone. DuckDB binds that as a column name, so the wholecollect()fails:The same happens for
> float("-inf"),== np.inf, comparisons withnan, and so on. These are common bounds in numeric filters. The parse step (SQLExpression) acceptsNoneas an identifier, so the existing "fall back to polars" path never triggers.A real null literal serializes differently (
{"Scalar": {"Null": "Float64"}}), so anullfloat value always means a non-finite number. We can't tell which one it is, so the literal can't be translated.Fix
In the scalar numeric branch of
_pl_tree_to_sql, raiseNotImplementedErrorwhen the value isnull. The predicate is then not pushed down, and polars applies it to the batches (the existing fallback).Tests
tests/fast/arrow/test_polars.py::test_polars_lazy_pushdown_non_finite_float[FLOAT|DOUBLE]builds a column containing1,inf,-inf,nanandNULL. For< inf,> -inf,== infand>= nan, it checks that the predicate is not pushed down and that the lazy result equals the eager polars result.On the base commit (f4f4ad2) both cases fail with the
BinderExceptionabove. With the fix they pass. The rest oftest_polars.pypasses too, excepttest_polars_from_json*, which fails identically before and after in my environment (prebuilt 1.5.5_duckdbwith the sourceduckdb/package onPYTHONPATH).ruff check/ruff format --check(0.13.3) are clean, andmypyreports the same output as on the base.This PR was prepared by an AI agent (Claude Code, operating the breken-ai account). The failure above was reproduced end to end and the tests were run locally, red on the base and green on the fix.