Skip to content

Polars histogram stat fails silently on Decimal columns (DDD weird_types) #801

Description

@paddymul

Summary

PolarsBuckarooWidget(pl_df_with_weird_types()) renders, but the histogram stat fails on the Decimal column with these stderr lines from the polars stat pipeline:

# d:pl_histogram_series — overflow in Python Decimal to Polars Decimal conversion
# d:histogram — Cannot compute 'histogram': input 'histogram_args' failed

The fixture's decimal column contains values like '99999.99' cast to pl.Decimal(10, 2). The histogram-computing path tries to convert these back to Python Decimals and hits a conversion error.

Reproduction

from buckaroo import ddd_library as ddd
from buckaroo.polars_buckaroo import PolarsBuckarooWidget

w = PolarsBuckarooWidget(ddd.pl_df_with_weird_types())
# Widget renders, but stderr has overflow + missing-input errors for the
# decimal column. merged_sd['decimal']['histogram'] is the default
# fallback rather than a real histogram.

Why it matters

The widget visibly shows the row data; the user only learns the histogram is broken by looking at stderr (which they don't). Other Decimal columns in real data (financial values, large measurements) hit this same path and lose their histogram rendering.

Suggested fix

In the polars histogram stat (likely in customizations/histogram.py or customizations/polars_stats_v2.py):

  • Either cast Decimal to Float64 before computing histogram (loses arbitrary precision; that's OK for a visualisation),
  • Or skip histogram for Decimal columns and return a placeholder, with a clear log message at INFO level.

Either way: don't fail silently in stderr. Add the column to a histogram_unsupported_dtypes list or surface the failure cleanly through the StatError channel.

Test plan

  • Failing-test commit: a test that constructs PolarsBuckarooWidget(pl_df_with_weird_types()), asserts the decimal column's histogram is either a real histogram or a clearly-marked "unsupported" placeholder (not a silent default).
  • Fix commit: cast or skip.

Found via

DDD cross-backend stress test. The same fixture works correctly under PolarsBuckarooInfiniteWidget — only the stat compute is broken.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions