Skip to content

Histogram fails to load when null values present in x-axis variable (regression from 4.1.2, occured in 5.0.0rc3, present in 6.0.0rc2) #33738

Closed

Description

@sfirke

Bug description

A histogram that rendered fine in 4.1.2 fails to render in 5.0.0rc3:

Image

The issue is that there are NULL values in the x-axis variable. When I add a "Is Not Null" filter the chart renders in 5.0.0rc3.

Previously these were excluded automatically and the chart would render, which is a reasonable behavior.

I found this error message confusing as it looked like a SQL problem but the chart's underlying SQL did not change. And it's not so much "non-numeric values" as it is NULLs since this is a numeric column.

The logs:

2025-06-11 02:48:29,472:WARNING:superset.views.error_handling:Exception
Traceback (most recent call last):
  File "/app/.venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/.venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/app/.venv/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 101, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 120, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1369, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 304, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/charts/data/api.py", line 260, in data
    return self._get_data_response(
  File "/app/superset/utils/log.py", line 304, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/charts/data/api.py", line 423, in _get_data_response
    result = command.run(force_cached=force_cached)
  File "/app/superset/commands/chart/data/get_data_command.py", line 45, in run
    payload = self._query_context.get_payload(
  File "/app/superset/common/query_context.py", line 102, in get_payload
    return self._processor.get_payload(cache_query_context, force_cached)
  File "/app/superset/common/query_context_processor.py", line 752, in get_payload
    query_results = [
  File "/app/superset/common/query_context_processor.py", line 753, in <listcomp>
    get_query_results(
  File "/app/superset/common/query_actions.py", line 227, in get_query_results
    return result_func(query_context, query_obj, force_cached)
  File "/app/superset/common/query_actions.py", line 103, in _get_full
    payload = query_context.get_df_payload(query_obj, force_cached=force_cached)
  File "/app/superset/common/query_context.py", line 123, in get_df_payload
    return self._processor.get_df_payload(
  File "/app/superset/common/query_context_processor.py", line 162, in get_df_payload
    query_result = self.get_query_result(query_obj)
  File "/app/superset/common/query_context_processor.py", line 287, in get_query_result
    df = query_object.exec_post_processing(df)
  File "/app/superset/common/query_object.py", line 452, in exec_post_processing
    df = getattr(pandas_postprocessing, operation)(df, **options)
  File "/app/superset/utils/pandas_postprocessing/histogram.py", line 56, in histogram
    raise ValueError(f"Column '{column}' contains non-numeric values")
ValueError: Column 'days_active' contains non-numeric values
2025-06-11 02:48:29,472:ERROR:superset.views.error_handling:Column 'days_active' contains non-numeric values
Traceback (most recent call last):
  File "/app/.venv/lib/python3.10/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/app/.venv/lib/python3.10/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/app/.venv/lib/python3.10/site-packages/flask_appbuilder/security/decorators.py", line 101, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 120, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1369, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 304, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/charts/data/api.py", line 260, in data
    return self._get_data_response(
  File "/app/superset/utils/log.py", line 304, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/charts/data/api.py", line 423, in _get_data_response
    result = command.run(force_cached=force_cached)
  File "/app/superset/commands/chart/data/get_data_command.py", line 45, in run
    payload = self._query_context.get_payload(
  File "/app/superset/common/query_context.py", line 102, in get_payload
    return self._processor.get_payload(cache_query_context, force_cached)
  File "/app/superset/common/query_context_processor.py", line 752, in get_payload
    query_results = [
  File "/app/superset/common/query_context_processor.py", line 753, in <listcomp>
    get_query_results(
  File "/app/superset/common/query_actions.py", line 227, in get_query_results
    return result_func(query_context, query_obj, force_cached)
  File "/app/superset/common/query_actions.py", line 103, in _get_full
    payload = query_context.get_df_payload(query_obj, force_cached=force_cached)
  File "/app/superset/common/query_context.py", line 123, in get_df_payload
    return self._processor.get_df_payload(
  File "/app/superset/common/query_context_processor.py", line 162, in get_df_payload
    query_result = self.get_query_result(query_obj)
  File "/app/superset/common/query_context_processor.py", line 287, in get_query_result
    df = query_object.exec_post_processing(df)
  File "/app/superset/common/query_object.py", line 452, in exec_post_processing
    df = getattr(pandas_postprocessing, operation)(df, **options)
  File "/app/superset/utils/pandas_postprocessing/histogram.py", line 56, in histogram
    raise ValueError(f"Column '{column}' contains non-numeric values")
ValueError: Column 'days_active' contains non-numeric values

Screenshots/recordings

No response

Superset version

5.0.0rc3

Python version

3.9

Node version

16

Browser

Firefox

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Activity

  1. added
    #bug:regression
    viz:charts:histogram
    on Jun 11, 2025
  2. changed the title [-]Histogram fails to load with null values in x-axis (regression from 4.1.2 -> 5.0.0rc3)[/-] [+]Histogram fails to load when null values present in x-axis variable (regression from 4.1.2 -> 5.0.0rc3)[/+] on Jun 11, 2025
  3. dosubot commented on Jun 11, 2025

    @dosubot

    This regression is due to stricter null handling in the backend histogram logic starting in 5.0.0rc3. The backend now converts the histogram column to numeric, and if any nulls (NaNs) remain, it raises a ValueError and blocks rendering—even if those nulls are just missing values in an otherwise numeric column. In previous versions, nulls were silently dropped and the chart rendered as expected. The frontend does not handle nulls; it expects already-cleaned data from the backend. There is currently no configuration or UI option to change this behavior—nulls are always dropped, and if any remain after conversion, the chart fails to render source.

    As a workaround, you can add an "Is Not Null" filter to your chart, or preprocess your data to remove or fill nulls before rendering the histogram. If you want to see nulls handled differently (for example, binned as a separate category), the backend logic would need to be adjusted to allow this.

    Let me know if you want more details on where this logic lives or how to patch it.

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about superset with Dosu Add Dosu to your team

  4. rusackas commented on Jun 11, 2025

    @rusackas
    Member

    Would you consider this a 5.0.0 blocker? CC @michael-s-molina

  5. moved this from New to Non-blockers in Apache Superset 5.0.0on Jun 18, 2025
  6. added
    good first issue
    on Aug 14, 2025
  7. panrach commented on Oct 1, 2025

    @panrach
    Contributor

    Hi! I was able to reproduce this:

    • went to a dataset and selected the histogram graph
    • added an "is not null" filter on a selected column
    Image

    Were you able to resolve this issue or find a workaround?

  8. changed the title [-]Histogram fails to load when null values present in x-axis variable (regression from 4.1.2 -> 5.0.0rc3)[/-] [+]Histogram fails to load when null values present in x-axis variable (regression from 4.1.2, occured in 5.0.0rc3, present in 6.0.0rc2)[/+] on Oct 1, 2025
  9. sfirke commented on Oct 1, 2025

    @sfirke
    MemberAuthor

    This is still broken in 6.0.0rc2 but I'm using the workaround suggested by Dosu bot.

    Try adding a filter for reply_count IS NOT NULL. In your example bot_id seems irrelevant, it's a matter of the column you're computing the histogram buckets on.

    Following from my first screenshot, here is the filter that makes it work:

    Image
  10. panrach commented on Oct 2, 2025

    @panrach
    Contributor

    You're right! Sorry about that, I misunderstood.
    I was able to recreate the issue and your workaround rendered the graph. Thank you!

    Image
  11. janani-gurram commented on Oct 2, 2025

    @janani-gurram
    Contributor

    Hi there!

    My group and I are students in the Software Engineering (CSCD01) course at the University of Toronto. We'd like to be assigned to this issue and work on a fix that will render the histogram even if the x-axis variable contains NULL values.

    Thanks!

    @janani-gurram @panrach @zayleak @andre-fong @FirozaAB

  12. sfirke commented on Oct 2, 2025

    @sfirke
    MemberAuthor

    @janani-gurram go for it! This shouldn't be a hugely complex fix and it seems no one else is working on it

  13. 2 remaining items

  14. panrach commented on Oct 5, 2025

    @panrach
    Contributor

    Hi!

    We are currently discussing a solution and wanted to ask what the expected behaviour of the histogram should be if all values in the x-axis variable are NULL.
    Ie. should it render an empty histogram or display the "no results were returned" message?

    Thank you!

  15. sfirke commented on Oct 5, 2025

    @sfirke
    MemberAuthor
  16. janani-gurram commented on Oct 9, 2025

    @janani-gurram
    Contributor

    We’re proposing the following fix to address this issue:

    • before calling to_numeric, we first apply dropna() on the input DataFrame
    • if the DataFrame is empty after dropping nulls, we return the empty DataFrame
    • otherwise, we continue as usual

    We also plan to add test cases to validate this behavior when the target column has all nulls (with and without grouping) and when the target column has some nulls (with and without grouping).

    We’d appreciate any community feedback on this approach

  17. sfirke commented on Oct 9, 2025

    @sfirke
    MemberAuthor

    Sounds good to me! I'm not sure you need to say the second bullet, I would think that "continue as usual" means return the empty DataFrame. But at any rate, please go ahead.

  18. panrach commented on Oct 14, 2025

    @panrach
    Contributor

    Thank you for the feedback!

    We also originally thought that the second bullet was unnecessary, but we caught a problem with this approach when writing unit tests.

    If we exclude the second point and don't return early, there are 2 problems that happen:

    1. Without grouping, rather than displaying "no results returned", a histogram with no bars gets rendered
    2. With grouping, an error gets displayed because unstack expects a MultiIndex but the DataFrame is empty

    With that being said, if the DataFrame is empty after dropping empty values, is returning the empty DataFrame a reasonable approach?

  19. sfirke commented on Oct 15, 2025

    @sfirke
    MemberAuthor

    Yep that sounds great! Thanks for the explanation, it sounds like you are taking a thorough approach.

  20. janani-gurram commented on Oct 17, 2025

    @janani-gurram
    Contributor

    Hi, we’ve submitted a PR with our proposed fix: #35693. Feedback is welcome!

  21. moved this from Non-blockers to Done in Apache Superset 5.0.0on Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

#bug:regressiongood first issueviz:charts:histogram

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions