Skip to content

Commit

Permalink
patch: fix duckdb narwhals_to_native_dtype for Int32 and UInt32 (
Browse files Browse the repository at this point in the history
…#1857)

patch: fix duckdb narwhals_to_native_dtype Int32 and UInt32
  • Loading branch information
FBruzzesi authored Jan 24, 2025
1 parent 67b1ae4 commit 03056f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions narwhals/_duckdb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ 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):
return "TINYINT"
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
Expand Down
5 changes: 3 additions & 2 deletions tests/expr_and_series/cast_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@
}

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")
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
Expand All @@ -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()

Expand Down

0 comments on commit 03056f5

Please sign in to comment.