diff --git a/narwhals/_arrow/utils.py b/narwhals/_arrow/utils.py index 6f7517aeb..b8294839c 100644 --- a/narwhals/_arrow/utils.py +++ b/narwhals/_arrow/utils.py @@ -51,7 +51,7 @@ def translate_dtype(dtype: Any) -> dtypes.DType: return dtypes.Duration() if pa.types.is_dictionary(dtype): return dtypes.Categorical() - raise AssertionError + return dtypes.Unknown() # pragma: no cover def narwhals_to_native_dtype(dtype: dtypes.DType | type[dtypes.DType]) -> Any: diff --git a/narwhals/_duckdb/dataframe.py b/narwhals/_duckdb/dataframe.py index b7b679208..8de244658 100644 --- a/narwhals/_duckdb/dataframe.py +++ b/narwhals/_duckdb/dataframe.py @@ -42,12 +42,7 @@ def map_duckdb_dtype_to_narwhals_dtype( return dtypes.Boolean() if duckdb_dtype == "INTERVAL": return dtypes.Duration() - msg = ( # pragma: no cover - f"Invalid dtype, got: {duckdb_dtype}.\n\n" - "If you believe this dtype should be supported in Narwhals, " - "please report an issue at https://github.com/narwhals-dev/narwhals." - ) - raise AssertionError(msg) + return dtypes.Unknown() class DuckDBInterchangeFrame: diff --git a/narwhals/_ibis/dataframe.py b/narwhals/_ibis/dataframe.py index 2e7bb0a1d..e2baa4ec4 100644 --- a/narwhals/_ibis/dataframe.py +++ b/narwhals/_ibis/dataframe.py @@ -40,12 +40,7 @@ def map_ibis_dtype_to_narwhals_dtype( return dtypes.Date() if ibis_dtype.is_timestamp(): return dtypes.Datetime() - msg = ( # pragma: no cover - f"Invalid dtype, got: {ibis_dtype}.\n\n" - "If you believe this dtype should be supported in Narwhals, " - "please report an issue at https://github.com/narwhals-dev/narwhals." - ) - raise AssertionError(msg) + return dtypes.Unknown() # pragma: no cover class IbisInterchangeFrame: diff --git a/tests/frame/interchange_schema_test.py b/tests/frame/interchange_schema_test.py index 56289dfd7..a73ca6259 100644 --- a/tests/frame/interchange_schema_test.py +++ b/tests/frame/interchange_schema_test.py @@ -3,6 +3,7 @@ from datetime import timedelta import duckdb +import pandas as pd import polars as pl import pytest @@ -211,3 +212,10 @@ def test_get_level() -> None: nw.get_level(nw.from_native(df.__dataframe__(), eager_or_interchange_only=True)) == "interchange" ) + + +def test_unknown_dtype() -> None: + df = pd.DataFrame({"a": [1, 2, 3]}) + rel = duckdb.from_df(df).select("cast(a as int128) as a") + result = nw.from_native(rel).schema + assert result == {"a": nw.Unknown}