This is an automated email from the ASF dual-hosted git repository.

sadpandajoe pushed a commit to branch fix-report-csv-empty-chart-data
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 4e15cdb274b81ca0080ffd4ffbea5ce393f4359f
Author: Joe Li <[email protected]>
AuthorDate: Sat Nov 14 10:29:01 2026 +0000

    fix(reports): skip post-processing for exports with no rows
    
    A chart whose query matches no rows exports only its column headers. 
Post-processing that export raised a KeyError for pivot tables, failing 
scheduled CSV and Excel reports. Pass such exports through unprocessed, as is 
already done for blank payloads.
    
    Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
---
 superset/charts/client_processing.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/superset/charts/client_processing.py 
b/superset/charts/client_processing.py
index 262efe11ed6..4730d71ee5c 100644
--- a/superset/charts/client_processing.py
+++ b/superset/charts/client_processing.py
@@ -1636,6 +1636,12 @@ def apply_client_processing(  # noqa: C901
                 data, form_data, datasource.data["verbose_map"] if datasource 
else None
             )
 
+        if len(df.index) == 0:
+            # An export with headers but no rows is passed through unprocessed:
+            # post-processors assume at least one row (e.g. pivoting drops the
+            # metric columns of an empty frame and then fails to select them).
+            continue
+
         # Serialized exports already carry labels from 
QueryContextProcessor.get_data.
         # Remapping those labels can mistake them for another column's raw 
name.
         if datasource and query["result_format"] == ChartDataResultFormat.JSON:

Reply via email to