Skip to content

fix(data): skip chart for nested/unknown column types#9876

Merged
mscolnick merged 1 commit into
mainfrom
kg/preview-column-skip-unknown
Jun 15, 2026
Merged

fix(data): skip chart for nested/unknown column types#9876
mscolnick merged 1 commit into
mainfrom
kg/preview-column-skip-unknown

Conversation

@kirangadhave

@kirangadhave kirangadhave commented Jun 13, 2026

Copy link
Copy Markdown
Member

Problem

Hovering a Polars Struct or List column in the datasets panel 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 and failed deep in Altair's dataframe-interchange serializer with ValueError: Unexpected DtypeKind: Struct(...). The caller caught the exception, logged a WARNING (which reads like a real failure), and shipped the raw serializer error to the frontend as ColumnPreview.error, as if charting had genuinely broken.

Fix

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. 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:
Screenshot 2026-06-12 at 6 57 31 PM

After:
Screenshot 2026-06-12 at 6 57 51 PM

Closes MO-6157

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.
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 13, 2026 1:55am

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Loading

Re-trigger cubic

@kirangadhave kirangadhave marked this pull request as ready for review June 13, 2026 01:58
Copilot AI review requested due to automatic review settings June 13, 2026 01:58
@kirangadhave kirangadhave added the bug Something isn't working label Jun 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_chart when the resolved FieldType is "unknown", returning no chart and no error.
  • Add a regression test ensuring Polars Struct columns 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.
Comment on lines +240 to +241
if column_type == "unknown":
return None, None, None, None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return a "No chart available" message. There may be users confused why there isn't a chart here.

@mscolnick mscolnick merged commit 88be960 into main Jun 15, 2026
46 of 52 checks passed
@mscolnick mscolnick deleted the kg/preview-column-skip-unknown branch June 15, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

4 participants