Skip to content

[Bug]: Version V1 got an unexpected keyword 'categories' when collecting duckdb enum dtype #2550

@zfaee

Description

@zfaee

Describe the bug

Version V1 got an unexpected keyword 'categories' when collecting duckdb enum dtype.

The keyword 'categories' is only supported in Version MAIN.

Steps or code to reproduce the bug

import duckdb
import narwhals as nw
import narwhals.stable.v1 as nwv1

enumdf = duckdb.sql("select 'a'::enum('a', 'b', 'c') as a")

nw.from_native(enumdf).collect_schema() # version main is ok
nwv1.from_native(enumdf).collect_schema() # version v1 error

Expected results

No error

Actual results

File .venv\lib\site-packages\narwhals\_duckdb\utils.py:128, in native_to_narwhals_dtype(duckdb_dtype, version)
    126 if duckdb_dtype_id == "enum":
    127     categories = duckdb_dtype.children[0][1]
--> 128     return dtypes.Enum(categories=categories)
    130 return _non_nested_native_to_narwhals_dtype(duckdb_dtype_id, version)

TypeError: Enum.__init__() got an unexpected keyword argument 'categories'

Please run narwhals.show_version() and enter the output below.

System:
    python: 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:01:37) [MSC v.1935 64 bit (AMD64)]
executable: .venv\Scripts\python.exe
   machine: Windows-10-10.0.19045-SP0

Python dependencies:
     narwhals: 1.39.0
       pandas: 2.2.3
       polars: 1.29.0
         cudf: 
        modin: 
      pyarrow: 20.0.0
        numpy: 2.2.5

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    high priorityYour PR will be reviewed very quickly if you address this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions