apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.35k stars 13.69k forks source link

500 Internal Server Error when exporting PivotTable as pivoted CSV and when any totals are shown #23738

Closed hakanonal closed 7 months ago

hakanonal commented 1 year ago

When you want to export a PivotTable as pivoted CSV and if the SHOW COLUMNS TOTALS or SHOW ROW TOTALS are clicked then 500 internal error page shows up instead of a CSV file to be downloaded. Please note that if none of the SHOW COLUMNS TOTALS and SHOW ROWS TOTALS is not clicked then there is no error. Here is the stack trace of the error in the docker app

2023-04-19 10:57:24,551:ERROR:superset.views.base:count() got an unexpected keyword argument 'axis'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/security/decorators.py", line 89, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/views/base_api.py", line 113, in wraps
    raise ex
  File "/app/superset/views/base_api.py", line 110, in wraps
    duration, response = time_function(f, self, *args, **kwargs)
  File "/app/superset/utils/core.py", line 1524, in time_function
    response = func(*args, **kwargs)
  File "/app/superset/utils/log.py", line 245, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/charts/data/api.py", line 244, in data
    return self._get_data_response(
  File "/app/superset/charts/data/api.py", line 396, in _get_data_response
    return self._send_chart_response(result, form_data, datasource)
  File "/app/superset/charts/data/api.py", line 343, in _send_chart_response
    result = apply_post_process(result, form_data, datasource)
  File "/app/superset/charts/post_processing.py", line 334, in apply_post_process
    processed_df = post_processor(df, form_data, datasource)
  File "/app/superset/charts/post_processing.py", line 234, in pivot_table_v2
    return pivot_df(
  File "/app/superset/charts/post_processing.py", line 172, in pivot_df
    subtotal = pivot_v2_aggfunc_map[aggfunc](
TypeError: count() got an unexpected keyword argument 'axis'

How to reproduce the bug

  1. Create a chart with type PivotTable
  2. Choose any dimensions and metrics you like
  3. Down below click in the options section click SHOW COLUMNS TOTALS or/and SHOW ROWS TOTALS
  4. click Update chart
  5. in the upper right corner click three dots to open settings menu of this chart.
  6. click Download -> Export to Pivoted .CSV option.
  7. see the 500 internal error

Expected results

I am expecting to download the CSV file.

Actual results

Instead of downloading a CSV file we are getting a 500 internal server error page like seen below.

Screenshots

image image

Environment

Checklist

Make sure to follow these steps before submitting your issue - thank you!

rusackas commented 7 months ago

I'm not sure if this is still an issue in current versions of Superset (3.x) - we haven't heard any other complaints. If it is, we can re-open this, or feel free to open a new issue with updated context and a reproducible case using example data. We're no longer supporting Superset 2.x or prior, and it's been a while since this thread saw any activity, so I'm closing this as stale.