Skip to content

Commit 4a79232

Browse files
Support Polars' Int128 / UInt128 (#299)
Related to #104
2 parents bf6b47c + 3786f34 commit 4a79232

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

duckdb/polars_io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,12 @@ def _pl_tree_to_sql(tree: _ExpressionTree) -> str:
207207
"Int16",
208208
"Int32",
209209
"Int64",
210+
"Int128",
210211
"UInt8",
211212
"UInt16",
212213
"UInt32",
213214
"UInt64",
215+
"UInt128",
214216
"Float32",
215217
"Float64",
216218
"Boolean",

tests/fast/arrow/test_polars.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,30 @@ def test_invalid_expr_json(self):
681681
with pytest.raises(AssertionError, match="The col name of a Column should be a str but got"):
682682
_pl_tree_to_sql(json.loads(bad_type_expr))
683683

684+
@pytest.mark.parametrize(
685+
("dtype", "test_value"),
686+
[
687+
(pl.Int8, 1),
688+
(pl.Int16, 1),
689+
(pl.Int32, 1),
690+
(pl.Int64, 1),
691+
(pl.Int128, 1),
692+
(pl.UInt8, 1),
693+
(pl.UInt16, 1),
694+
(pl.UInt32, 1),
695+
(pl.UInt64, 1),
696+
(pl.UInt128, 1),
697+
(pl.Float32, 1.0),
698+
(pl.Float64, 1.0),
699+
(pl.Boolean, True),
700+
],
701+
)
702+
def test_scalar_type_pushdown(self, dtype, test_value):
703+
"""Verify that literals of each scalar type can be pushed down."""
704+
expr = pl.col("a") == pl.lit(test_value, dtype=dtype)
705+
sql_expression = _predicate_to_expression(expr)
706+
assert sql_expression is not None, f"Pushdown failed for {dtype}"
707+
684708
def test_decimal_scale(self):
685709
scalar_decimal_no_scale = """
686710
{ "Scalar": {

0 commit comments

Comments
 (0)