fix(data): skip chart for nested/unknown column types#9876
Merged
Conversation
Hovering a Polars Struct or List column surfaced a confusing error and logged a spurious warning. These dtypes resolve to a FieldType of "unknown", but chart generation still ran the full pipeline, failing deep in Altair's dataframe-interchange serializer with "ValueError: Unexpected DtypeKind: Struct(...)". The caller caught it, logged a WARNING, and shipped the raw serializer error to the frontend as if charting had genuinely broken. Short-circuit _get_altair_chart for "unknown" field types, returning no chart and no error. The dtype is known to be unchartable up front, so there is nothing to attempt and nothing to report. Stats are unaffected and still compute on their own path.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant UI as Frontend UI
participant Preview as get_column_preview_dataset()
participant Chart as _get_altair_chart()
participant Table as Table Manager
participant Stats as Statistics Engine
participant Export as Altair Export
Note over UI,Export: Column Preview Flow
UI->>Preview: Request column preview
Preview->>Table: get_field_type(column_name)
Table-->>Preview: column_type, external_type
alt column_type == "unknown" (e.g., Polars Struct/List)
Preview->>Chart: _get_altair_chart(column_name)
Chart->>Table: get_field_type(column_name)
Table-->>Chart: column_type = "unknown"
Chart-->>Preview: Return (None, None, None, None)
Preview-->>UI: result(chart_spec=None, chart_code=None, error=None)
else column_type != "unknown"
Preview->>Chart: _get_altair_chart(column_name)
Chart->>Table: get_field_type(column_name)
Table-->>Chart: column_type (known type)
alt stats.total == 0
Chart-->>Preview: Return (None, None, "Table is empty", None)
else stats.total > 0
Chart->>Export: Serialize to Altair chart
alt Serialization succeeds
Export-->>Chart: Chart spec/code
Chart-->>Preview: Return chart_spec, chart_code
else Serialization fails
Export-->>Chart: ValueError
Chart-->>Preview: Return error
end
end
Preview->>Stats: Compute aggregation stats
Stats-->>Preview: Statistics data
Preview-->>UI: result(chart_spec, chart_code, error, stats)
end
Preview->>Stats: Compute aggregation stats (always)
Stats-->>Preview: Statistics data
Preview-->>UI: result(stats=statistics)
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves dataset column previews by avoiding Altair chart generation for nested/unchartable column dtypes that currently map to FieldType == "unknown" (e.g. Polars Struct/List), preventing confusing backend warnings and serializer errors from being surfaced to the frontend.
Changes:
- Short-circuit
_get_altair_chartwhen the resolvedFieldTypeis"unknown", returning no chart and no error. - Add a regression test ensuring Polars
Structcolumns produce stats but no chart and do not log warnings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
marimo/_data/preview_column.py |
Skips Altair chart generation entirely for "unknown" field types to avoid serializer failures. |
tests/_data/test_preview_column.py |
Adds coverage to ensure struct/nested columns return no chart/error and don’t emit warnings. |
mscolnick
approved these changes
Jun 13, 2026
Light2Dark
approved these changes
Jun 15, 2026
Comment on lines
+240
to
+241
| if column_type == "unknown": | ||
| return None, None, None, None |
Member
There was a problem hiding this comment.
Should we return a "No chart available" message. There may be users confused why there isn't a chart here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Hovering a Polars
StructorListcolumn in the datasets panel surfaced a confusing error and logged a spurious warning. These dtypes resolve to aFieldTypeof"unknown", but chart generation still ran the full pipeline and failed deep in Altair's dataframe-interchange serializer withValueError: Unexpected DtypeKind: Struct(...). The caller caught the exception, logged aWARNING(which reads like a real failure), and shipped the raw serializer error to the frontend asColumnPreview.error, as if charting had genuinely broken.Fix
Short-circuit
_get_altair_chartfor"unknown"field types, returning no chart and no error. The dtype is known to be unchartable up front, so there is nothing to attempt and nothing to report. The check lives right after the field-type lookup that the function already performs, so it adds no extra work. The stats path is on a separate branch and is unaffected, so aggregation stats still compute and display for these columns.Before:

After:

Closes MO-6157