innovark37 opened a new pull request, #41103:
URL: https://github.com/apache/superset/pull/41103
### SUMMARY
Scheduled report CSV/XLSX exports for Table charts with server-side
pagination used the saved chart query context from the preview path. That query
context contains the current page data query, where `row_limit` is based on
Server Page Length, not the configured Row limit.
This made report exports behave differently from frontend exports:
- Frontend export uses Row limit and starts from `row_offset = 0`.
- Report worker export used Server Page Length and could export only one
server-paginated page.
- The saved server pagination query context also includes an `is_rowcount`
query, which is useful for the table preview but unnecessary for file export.
This change makes the report worker send chart data requests using the same
payload shape as frontend downloads. For server-paginated table exports, the
worker prepares the saved query context for export by:
- setting the data query `row_limit` from `form_data.row_limit`;
- resetting `row_offset` to `0`;
- removing the `is_rowcount` query;
- posting to the chart data endpoint with `result_format` set to CSV/XLSX
and `result_type` set to post-processed.
Alternative considered: normalize this on the chart data backend instead of
in the worker. For example:
```python
def _normalize_server_paginated_export(
query_context: dict[str, Any],
) -> None:
"""Make a saved server-paginated table query match a UI download
query."""
if query_context.get("result_format") not in {
result_format.value for result_format in
ChartDataResultFormat.table_like()
}:
return
form_data = query_context.get("form_data") or {}
queries = query_context.get("queries") or []
if not form_data.get("server_pagination") or not queries:
return
queries[0]["row_limit"] = form_data.get("row_limit") or 0
queries[0]["row_offset"] = 0
query_context["queries"] = [
query for query in queries if not query.get("is_rowcount")
]
```
That would make the rule closer to the chart data execution layer, but it
would also affect all POST callers of the chart data API. The worker-level
change keeps the behavior scoped to scheduled report exports and avoids
changing the public chart data API contract.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable. This is a backend report export fix.
### TESTING INSTRUCTIONS
1. Create a Table chart with server-side pagination enabled.
2. Set Server Page Length lower than Row limit.
3. Create a scheduled report export for CSV or XLSX.
4. Verify the exported file uses the configured Row limit, not Server Page
Length.
5. Verify the export does not issue/use the row count query.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [x] Required feature flags: `ALERT_REPORTS`
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]