narwhals icon indicating copy to clipboard operation
narwhals copied to clipboard

error reporting: unify "column not found" error message for DuckDB / spark-like

Open MarcoGorelli opened this issue 8 months ago • 1 comments

import narwhals as nw
import polars as pl

import duckdb

df = pl.DataFrame({'a': [1,2,3]})
nw.from_native(df).select(nw.col('b'))
nw.from_native(df.to_pandas()).select(nw.col('b'))
nw.from_native(df.to_arrow()).select(nw.col('b'))
nw.from_native(duckdb.table('df')).select(nw.col('b'))

All of the above, except the last one, raise nw.exceptions.ColumnNotFoundError

we should catch duckdb.BinderError and, if 'column cannot be referenced before it is defined' is in the error message, raise nw.exceptions.ColumnNotFoundError, similarly to how we do for other backends

Then we should be able to avoid xfails in select_test.py test_missing

MarcoGorelli avatar May 03 '25 09:05 MarcoGorelli

I'll take this one 👀

EdAbati avatar May 04 '25 19:05 EdAbati