Issue This issue has been seen in superset 0.26, 0.35, and the latest version of 0.36. When queries with more than one entires of Group by for Time-Series Table, the following error is showing up : Unexpected Error keys must be str, int, float, bool or None, not tuple How to reproduce this Error: Use any available data source to create a TIME-SERIES TABLE, add more than one Group by entries and run query

Trace log Traceback (most recent call last): File "/opt/superset/venv/lib/python3.6/site-packages/superset/views/base.py", line 120, in wraps return f(self, *args, **kwargs) File "/opt/superset/venv/lib/python3.6/site-packages/superset/utils/decorators.py", line 69, in wrapper return f(*args, **kwargs) File "/opt/superset/venv/lib/python3.6/site-packages/superset/views/core.py", line 1092, in explore_json viz_obj, csv=csv, query=query, results=results, samples=samples File "/opt/superset/venv/lib/python3.6/site-packages/superset/views/core.py", line 1014, in generate_json return data_payload_response(*viz_obj.payload_json_and_has_error(payload)) File "/opt/superset/venv/lib/python3.6/site-packages/superset/viz.py", line 478, in payload_json_and_has_error return self.json_dumps(payload), has_error File "/opt/superset/venv/lib/python3.6/site-packages/superset/viz.py", line 470, in json_dumps obj, default=utils.json_int_dttm_ser, ignore_nan=True, sort_keys=sort_keys File "/opt/superset/venv/lib64/python3.6/site-packages/simplejson/_init_.py", line 412, in dumps **kw).encode(obj) File "/opt/superset/venv/lib64/python3.6/site-packages/simplejson/encoder.py", line 296, in encode chunks = self.iterencode(o, _one_shot=True) File "/opt/superset/venv/lib64/python3.6/site-packages/simplejson/encoder.py", line 378, in iterencode return _iterencode(o, 0) TypeError: keys must be str, int, float, bool or None, not tuple

Comment From: kamalkeshavani-aiinside

@junlincc Please add appropriate tag to this issue. I can reproduce this issue still in v1.1.0 and master.

Comment From: tugra-alp

This issue is still exist in v1.3.

Comment From: stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Comment From: grzesuav

seen that on 1.4

Comment From: emgoryaynova

Still exists in 2.0.1

Comment From: jinyangzhen

yes, still exists in 2.0.1. Any plan to fix

Comment From: mtrentz

Also had the same problem with the same error.

The result query runs fine in postgres.

Comment From: billcrook

I see this in 3.0.1 with a time-series table chart.

Comment From: rusackas

This obviously isn't getting much traction, as it doesn't seem to be ruining the day of any core committers. I'm tempted to close it since it's over three years old, but I'm guessing it still exists. Anyone on this thread willing to open a PR?

Comment From: Aset-21

It would be cool to fix this error in the time-series table chart.

Comment From: kyledufrane

still exists in 2.1.3

Comment From: rusackas

2.x is no longer supported. We currently support 3.1 and 4.0. Can anyone confirm the issue still exists in supported versions?

Comment From: tfzrch

still exists in 4.0.1

Comment From: VikramKumarArammeem

@rusackas Same issue still facing with 3.1.2

Comment From: michael-s-molina

Thank you for reporting this issue. However, the issue was reported on a version of Superset that we no longer support or it does not contain a valid Superset version. As of this moment, we only actively support Superset 4.0 and 4.1. To maintain a more actionable Issues backlog, we're going to close this issue for now. If you (or anyone reading this) are still experiencing this on a currently supported version of Superset, please either reopen this Issue, or file a new one with updated context (screenshots, reproduction steps) and we'll do our best to support it. Thank you

Comment From: bluespring2812

Hi @michael-s-molina, I'm using Superset 4.1.1 and still unable to use group by with multiple dimensions (see the capture). Can you reopen this issue?

Image

Comment From: rusackas

This one has gone silent again for a good while. Let's see if @dosu has any helpful advice to unblock things here.

Comment From: dosubot[bot]

The error "keys must be str, int, float, bool or None, not tuple" when using multiple "Group by" entries in the Time-Series Table is a known and persistent issue, confirmed in Superset 4.1.1 and earlier versions. The root cause is in the backend logic: when multiple columns are used for "group by", the resulting pandas DataFrame pivot operation can produce dictionary keys as tuples (representing multi-indexes), which are not valid for JSON serialization and thus trigger this error.

The relevant code is in the TimeTableViz class in superset/viz.py. When "groupby" is set, the get_data method pivots the DataFrame and returns pt.to_dict(orient="index"). If the index or columns are multi-level (tuples), this leads to the serialization error you see. The frontend transformProps.ts expects flat keys and does not handle tuple keys either. The backend also restricts "group by" to a single metric, but the error can still occur with multiple groupby columns and a single metric if the resulting DataFrame index is a tuple rather than a string or int (source).

There is currently no documented fix or workaround in the latest supported versions. If you need to use multiple group by columns in a time-series table, you may need to flatten the resulting multi-index in the backend before serialization, or use a different visualization that supports this use case. If you are comfortable with code, reviewing and updating the get_data method in TimeTableViz to flatten tuple keys to strings before returning the dictionary would address the serialization issue.

No recent changes or fixes for this issue were found in the repository or documentation. If you need a workaround, consider using a Table chart instead of Time-Series Table, as it handles group by columns differently and does not rely on the same pivot logic (source).

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

Comment From: HarshithGamini

The root cause is the backend logic to get_data( ) in class TimeTableViz(BaseViz):

    @deprecated(deprecated_in="3.0")
    def get_data(self, df: pd.DataFrame) -> VizData:
        if df.empty:
            return None

        columns = None
        values: list[str] | str = self.metric_labels
        if self.form_data.get("groupby"):
            values = self.metric_labels[0]
            columns = get_column_names(self.form_data.get("groupby"))
        pt = df.pivot_table(index=DTTM_ALIAS, columns=columns, values=values)
        pt.index = pt.index.map(str)
        pt = pt.sort_index()
        return {
            "records": pt.to_dict(orient="index"),
            "columns": list(pt.columns),
            "is_group_by": bool(self.form_data.get("groupby")),
        }

@rusackas, Is this supposed to be deprecated in 3.0? The time-series table chart still uses it as of latest master, we could implement a fix as mentioned by @dosu to flatten tuple keys to strings before returning the dictionary.