From 4d490c103fdb12a11b699d0307385563c597f37d Mon Sep 17 00:00:00 2001 From: FBruzzesi Date: Thu, 23 Jan 2025 22:05:24 +0100 Subject: [PATCH] patch: fix duckdb narwhals_to_native_dtype Int32 and UInt32 --- narwhals/_duckdb/utils.py | 4 ++-- tests/expr_and_series/cast_test.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/narwhals/_duckdb/utils.py b/narwhals/_duckdb/utils.py index 5e7f62219..f38b3d4c0 100644 --- a/narwhals/_duckdb/utils.py +++ b/narwhals/_duckdb/utils.py @@ -163,7 +163,7 @@ def narwhals_to_native_dtype(dtype: DType | type[DType], version: Version) -> st if isinstance_or_issubclass(dtype, dtypes.Int64): return "BIGINT" if isinstance_or_issubclass(dtype, dtypes.Int32): - return "INT" + return "INTEGER" if isinstance_or_issubclass(dtype, dtypes.Int16): return "SMALLINT" if isinstance_or_issubclass(dtype, dtypes.Int8): @@ -171,7 +171,7 @@ def narwhals_to_native_dtype(dtype: DType | type[DType], version: Version) -> st if isinstance_or_issubclass(dtype, dtypes.UInt64): return "UBIGINT" if isinstance_or_issubclass(dtype, dtypes.UInt32): - return "UINT" + return "UINTEGER" if isinstance_or_issubclass(dtype, dtypes.UInt16): # pragma: no cover return "USMALLINT" if isinstance_or_issubclass(dtype, dtypes.UInt8): # pragma: no cover diff --git a/tests/expr_and_series/cast_test.py b/tests/expr_and_series/cast_test.py index c725d8fd9..602123639 100644 --- a/tests/expr_and_series/cast_test.py +++ b/tests/expr_and_series/cast_test.py @@ -55,6 +55,7 @@ } SPARK_INCOMPATIBLE_COLUMNS = {"e", "f", "g", "h", "l", "o", "p"} +DUCKDB_INCOMPATIBLE_COLUMNS = {"l", "o", "p"} @pytest.mark.filterwarnings("ignore:casting period[M] values to int64:FutureWarning") @@ -62,8 +63,6 @@ def test_cast( constructor: Constructor, request: pytest.FixtureRequest, ) -> None: - if "duckdb" in str(constructor): - request.applymarker(pytest.mark.xfail) if "pyarrow_table_constructor" in str(constructor) and PYARROW_VERSION <= ( 15, ): # pragma: no cover @@ -74,6 +73,8 @@ def test_cast( if "pyspark" in str(constructor): incompatible_columns = SPARK_INCOMPATIBLE_COLUMNS # pragma: no cover + elif "duckdb" in str(constructor): + incompatible_columns = DUCKDB_INCOMPATIBLE_COLUMNS # pragma: no cover else: incompatible_columns = set()