Skip to content

Commit 2c9aa95

Browse files
committed
fix(python): reconcile date literals with typed scalars after rebase
Signed-off-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E92wUoS3LaqWVJmmS7vKVq
1 parent e5cfad2 commit 2c9aa95

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

‎vortex-python/python/vortex/polars_.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ def _polars_to_vortex(expr: dict[str, Any]) -> ve.Expr:
104104
elif "Decimal" in scalar:
105105
value, precision, scale = scalar["Decimal"]
106106
return ve.literal(_dtype.decimal(precision=precision, scale=scale), value)
107-
elif len(scalar) == 1 and next(iter(scalar)) in _LITERAL_TYPES:
108-
dtype, value = next(iter(scalar.items()))
109107
elif "Date" in scalar:
110108
return ve.literal(_dtype.date("days"), scalar["Date"])
109+
elif len(scalar) == 1 and next(iter(scalar)) in _LITERAL_TYPES:
110+
dtype, value = next(iter(scalar.items()))
111111
else:
112112
raise ValueError(f"Cannot convert to Vortex: unsupported Polars scalar value type {scalar}")
113113

‎vortex-python/test/test_polars_.py‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
import math
55
import os
6-
from datetime import time
6+
from datetime import date, time
77
from decimal import Decimal
8-
from datetime import date
98

109
import polars as pl
1110
import pyarrow as pa
@@ -163,12 +162,8 @@ def test_is_not_null_predicate_pushdown(tmp_path):
163162
assert result["id"].to_list() == [0, 2]
164163

165164

166-
def test_polars_date_literals():
167-
frame = pl.DataFrame({"x": [date(2024, 1, 1), None, date(2024, 1, 3)]})
168165
def test_polars_date_literals(tmp_path):
169-
frame = pl.DataFrame(
170-
{"id": [0, 1, 2, 3], "x": [date(2024, 1, 1), date(2024, 1, 2), None, date(2024, 1, 3)]}
171-
)
166+
frame = pl.DataFrame({"id": [0, 1, 2, 3], "x": [date(2024, 1, 1), date(2024, 1, 2), None, date(2024, 1, 3)]})
172167
expr = pl.col("x") >= date(2024, 1, 2)
173168
path = tmp_path / "date_literals.vortex"
174169
vx.io.write(vx.array(frame.to_arrow()), str(path))

0 commit comments

Comments
 (0)