Skip to content

Commit c2be54c

Browse files
authored
fix: pandas bug when data is blank on post-processing (apache#20629)
* fix pandas bug when data is blank on post-processing * account for multiple queries when data is blank
1 parent dfab521 commit c2be54c

File tree

2 files changed

+605
-3
lines changed

2 files changed

+605
-3
lines changed

superset/charts/post_processing.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,17 @@ def apply_post_process(
324324
post_processor = post_processors[viz_type]
325325

326326
for query in result["queries"]:
327+
if query["result_format"] not in (rf.value for rf in ChartDataResultFormat):
328+
raise Exception(f"Result format {query['result_format']} not supported")
329+
330+
if not query["data"]:
331+
# do not try to process empty data
332+
continue
333+
327334
if query["result_format"] == ChartDataResultFormat.JSON:
328335
df = pd.DataFrame.from_dict(query["data"])
329336
elif query["result_format"] == ChartDataResultFormat.CSV:
330337
df = pd.read_csv(StringIO(query["data"]))
331-
else:
332-
raise Exception(f"Result format {query['result_format']} not supported")
333338

334339
processed_df = post_processor(df, form_data, datasource)
335340

0 commit comments

Comments
 (0)