You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2023/04/19 15:49:58 UTC
[superset] branch master updated: chore(chart-data): add post processing error message to response (#23734)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 306fb22021 chore(chart-data): add post processing error message to response (#23734)
306fb22021 is described below
commit 306fb22021f84e7dd527c88c00be1f8e7cca0d8c
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Wed Apr 19 18:49:33 2023 +0300
chore(chart-data): add post processing error message to response (#23734)
---
superset/common/query_context_processor.py | 2 +-
tests/integration_tests/charts/data/api_tests.py | 27 ++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/superset/common/query_context_processor.py b/superset/common/query_context_processor.py
index 019422db39..56f07dcb64 100644
--- a/superset/common/query_context_processor.py
+++ b/superset/common/query_context_processor.py
@@ -237,7 +237,7 @@ class QueryContextProcessor:
try:
df = query_object.exec_post_processing(df)
except InvalidPostProcessingError as ex:
- raise QueryObjectValidationError from ex
+ raise QueryObjectValidationError(ex.message) from ex
result.df = df
result.query = query
diff --git a/tests/integration_tests/charts/data/api_tests.py b/tests/integration_tests/charts/data/api_tests.py
index db81488c3f..5315bbbaed 100644
--- a/tests/integration_tests/charts/data/api_tests.py
+++ b/tests/integration_tests/charts/data/api_tests.py
@@ -481,6 +481,33 @@ class TestPostChartDataApi(BaseTestChartDataApi):
self.assertIn("sum__num__yhat_lower", row)
self.assertEqual(result["rowcount"], 47)
+ @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
+ def test_chart_data_invalid_post_processing(self):
+ """
+ Chart data API: Ensure incorrect post processing returns correct response
+ """
+ query_context = self.query_context_payload
+ query = query_context["queries"][0]
+ query["columns"] = ["name", "gender"]
+ query["post_processing"] = [
+ {
+ "operation": "pivot",
+ "options": {
+ "drop_missing_columns": False,
+ "columns": ["gender"],
+ "index": ["name"],
+ "aggregates": {},
+ },
+ },
+ ]
+ rv = self.post_assert_metric(CHART_DATA_URI, query_context, "data")
+ assert rv.status_code == 400
+ data = json.loads(rv.data.decode("utf-8"))
+ assert (
+ data["message"]
+ == "Error: Pivot operation must include at least one aggregate"
+ )
+
@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_with_query_result_type_and_non_existent_filter__filter_omitted(self):
self.query_context_payload["queries"][0]["filters"] = [