perspective-dev/perspective · error · ValueError
Unknown Polars type
Error message
Unknown Polars type '{dtype}' What it means
polars_type_to_psp maps Polars dtypes to Perspective ColumnTypes; when a dtype falls outside the handled set (e.g. pl.List, pl.Struct, pl.Time, pl.Decimal, or Enum), no mapping exists and the virtual server cannot build the schema, so it raises. Generic sentinel ValueError raised by the converter.
Solutions
- Cast unsupported columns before loading, e.g. df.with_columns(pl.col("c").cast(pl.Utf8))
- Drop or exclude non-primitive columns (List/Struct) from the table
- Extend polars_type_to_psp with a mapping for the missing dtype if it should be supported
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at rust/perspective-python/perspective/virtual_servers/polars.py:317 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of perspective-dev/perspective@11c8238c0c (2026-09-09).
Data as JSON: /api/errors/68579ae490628664.
Report an issue: GitHub.
Appendix: source
Thrown at rust/perspective-python/perspective/virtual_servers/polars.py:317
def polars_type_to_psp(dtype):
"""Convert a Polars `dtype` to a Perspective `ColumnType`."""
if dtype in (pl.Utf8, pl.String):
return "string"
if dtype == pl.Categorical:
return "string"
if dtype in (pl.Int8, pl.Int16, pl.Int32, pl.UInt8, pl.UInt16):
return "integer"
if dtype in (pl.Int64, pl.UInt64, pl.UInt32, pl.Float32, pl.Float64):
return "float"
if dtype == pl.Date:
return "date"
if dtype == pl.Boolean:
return "boolean"
if isinstance(dtype, pl.Datetime) or dtype == pl.Datetime:
return "datetime"
msg = f"Unknown Polars type '{dtype}'"
raise ValueError(msg)
def apply_filters(df, filters):
"""Apply a list of filter configs to a DataFrame."""
if not filters:
return df
mask = pl.lit(True)
for filt in filters:
col_name = filt[0]
op = filt[1]
value = filt[2] if len(filt) > 2 else None
if value is None:
continue
col_expr = pl.col(col_name)
if op == "==":View on GitHub (pinned to 11c8238c0c)