Skip to content

Commit c3cf406

Browse files
Polars lazyframe pushdown fixes (#347)
2 parents 72a4200 + f765dcc commit c3cf406

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

duckdb/polars_io.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ def _pl_tree_to_sql(tree: _ExpressionTree) -> str:
130130
)
131131
return str(int_literal)
132132

133+
if node_type == "Float":
134+
# Direct float literals
135+
float_literal = tree[node_type]
136+
assert isinstance(float_literal, (float, int, str)), (
137+
f"The value of a Float should be a float, int or str but got {type(float_literal)}"
138+
)
139+
return str(float_literal)
140+
133141
if node_type == "Function":
134142
# Handle boolean functions like IsNull, IsNotNull
135143
func_tree = tree[node_type]
@@ -162,8 +170,8 @@ def _pl_tree_to_sql(tree: _ExpressionTree) -> str:
162170
if node_type == "Cast":
163171
cast_tree = tree[node_type]
164172
assert isinstance(cast_tree, dict), f"A {node_type} should be a dict but got {type(cast_tree)}"
165-
if cast_tree.get("options") != "NonStrict":
166-
msg = f"Only NonStrict casts can be safely unwrapped, got {cast_tree.get('options')!r}"
173+
if cast_tree.get("options") not in ("NonStrict", "Strict"):
174+
msg = f"Only NonStrict/Strict casts can be safely unwrapped, got {cast_tree.get('options')!r}"
167175
raise NotImplementedError(msg)
168176
cast_expr = cast_tree["expr"]
169177
assert isinstance(cast_expr, dict), f"A {node_type} should be a dict but got {type(cast_expr)}"

0 commit comments

Comments
 (0)