aipiJuancho commented on code in PR #44624:
URL: https://github.com/apache/superset/pull/44624#discussion_r4114055657


##########
superset/charts/data/api.py:
##########
@@ -655,6 +649,24 @@ def _get_data_response(
         slice_: Slice | None = None,
     ) -> Response:
         """Get data response and optionally log is_cached information."""
+        query_context = command.query_context
+        if self._should_stream_before_execution(query_context, expected_rows):
+            # The client already decided to stream this export, so skip the
+            # regular execution: it would run the full query and hold every row
+            # in memory only to discard the result, and the streaming command
+            # runs the query again anyway. On large exports that first pass is
+            # long enough for proxies to drop the idle connection before the
+            # first byte is sent.
+            if not self._has_export_permission():
+                return self.response_403()
+            return self._create_streaming_csv_response(
+                {"query_context": query_context},
+                form_data,
+                filename=filename,
+                expected_rows=expected_rows,
+                slice_=slice_ or query_context.slice_,
+            )

Review Comment:
   Good catch — moved the streaming block under the existing try/except in 
228757f, so failures raised synchronously while building the streaming response 
(`validate()` -> `raise_for_access()`, and the SQL compilation inside `run()`) 
now go through the same 422/400 mapping as the regular path. Added a regression 
test covering both exception types.
   
   While at it, also addressed a related finding from the automated review: the 
shortcut now requires a single-query context (`len(queries) == 1`) — 
`StreamingCSVExportCommand` only exports `queries[0]`, while the regular path 
bundles multi-query results into a zip, so those contexts now keep the regular 
path (also tested).
   
   Unit suite green: 750 passed / 2 pre-existing xfails across `charts` + 
`commands/chart` + `common`; ruff clean.



-- 
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