aminghadersohi opened a new pull request, #40812:
URL: https://github.com/apache/superset/pull/40812

   ### TL;DR
   
   `pivot()` now normalises `columns=[]` to `columns=None` before any 
downstream logic, fixing a crash that produced "Failed to load chart data" for 
categorical bar charts with no groupby dimensions.
   
   ### Problem
   
   When a categorical bar chart (e.g. `echarts_timeseries_bar`) has no groupby 
dimensions:
   
   1. `buildQuery.ts` sets `series_columns: groupby` — when `groupby = []` this 
is `series_columns = []`.
   2. `pivotOperator.ts` evaluates `const columns = queryObject.series_columns 
|| queryObject.columns` — `[]` is truthy in JS, so `columns = []`.
   3. The backend receives `pivot(index=[x_axis], columns=[], aggregates=...)`.
   4. `pandas.DataFrame.pivot_table(columns=[])` raises on some pandas 
versions, which propagates as `InvalidPostProcessingError` → HTTP 400 → "Failed 
to load chart data".
   
   ### Fix
   
   One-line normalisation in `pivot.py`:
   
   ```python
   columns = columns or None
   ```
   
   Added before any downstream `if columns:` checks so the empty-list case is 
treated identically to the absent-columns case.
   
   ### Testing
   
   New test `test_pivot_with_empty_columns_list` verifies that 
`pivot(columns=[])` produces the same DataFrame as `pivot()` (no `columns` 
kwarg).
   
   ```
   pytest tests/unit_tests/pandas_postprocessing/test_pivot.py
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to