Produce a query's complete result as a file
What It Does
A person or schedule requests a CSV or Excel file for an executable query with its runtime values. Public delivery links verify their seven-day token and continued schedule-recipient membership, record a download and use the common invalid-link response for refusal.
The Flow
Open any saved source as the caller, substitute runtime values and compile the resulting query with current dataset access. Commit the queued file and queued-work row together, then nudge dispatch. Claim cross-workspace queue rows, publish each to the query-generator or report-renderer queue and remove accepted rows. Start unfinished work as the requester, read thousand-row keyset pages and stream CSV or Excel into multipart storage while recording progress. Record successful file size, rows and completion-based expiry. Authorize the requester or eligible schedule authority and issue a five-minute signed object link for a ready, unexpired file.
When Something Fails
Refuse inaccessible sources, invalid values or unavailable fields before creating the file request. Admission has not written export work at this point. A failed nudge leaves the periodic dispatcher to find the row. The durable request remains queued until dispatch succeeds. Rejected publication retains the request for a later claim. The file can wait longer, or receive duplicate delivery after a publish/delete interruption. Permanent request failures settle promptly; infrastructure errors redeliver until the final receive, with handled multipart uploads aborted. A claim or running row can remain until retry or reconciliation; no exclusive worker lease is established here. A completion write failure can cause rebuilding on redelivery. The stored object can exist while its row still says running. Other readers receive not found; unfinished and expired files receive their corresponding refusal. The storage object is not changed by download refusal.
Idempotency and Concurrency
Admission ties the queue identity to the export and fixes its storage key. Redelivery reuses unfinished work; a successful publish followed by a failed queue-row delete can produce another delivery. Interactive query exports use their own queue and configured worker concurrency, separate from scheduled delivery. Each generator processes one query page at a time.