Export
An export is a request of its own kind. It drops the grouping state and names its output columns, which an ordinary row query does not. The export scope chooses the page mode and nothing else in the compiler changes; streaming and the CSV file itself are described elsewhere.
the grouping addendum above, of which this is the sibling: the TRD's §6.1 states the export requirements and this is where the compile-time half of them is decided)
The TRD's EXP-1..EXP-8 span a wire contract, a compilation rule, a streaming obligation and a CSV writer. Only EXP-1 and EXP-2 have a compiled form at all — EXP-3 is streaming, and EXP-4..EXP-8 are the CSV writer's; none of them is restated here. So this addendum owns no new number: it refines the two that exist, splitting EXP-1's single paragraph into the two independent rules it actually contains — the request extension with its group carve-out, EXP-1(a), and the column list, EXP-1(b). Numbering the column list "EXP-3" is a mistake this repo has already made twice, in GRP-3 and in its restatement in SqlQueryBuilder; both are corrected.
What follows is what a compiler and its request adapter must do, pinned because #1650 found the two questions below answered inconsistently in the suite that was meant to pin them: whether an ordinary row query projects, and whether an export does.
EXP-1(a). The export is a request-shaped extension, and its group state is discarded. The wire request carries exportFormat: "csv" | "tsv", exportScope: "all" | "page" (default "all") and an optional ordered exportColumns: [{ colId, header? }] beside the ordinary AG Grid SSRM members — filterModel and sortModel are always honoured, unchanged, which is why nothing else about the compiled query differs. Three consequences, all of them the adapter's to apply before a compiler sees the IR:
exportFormatis what marks a request as an export, and it is not optional. AnexportScopeorexportColumnsarriving without one is a malformed request, not a row fetch with two ignorable properties: ignoring a scope returns one page where the client asked for the whole result set.exportFormatitself is otherwise compilation-inert —page-export/004and/005differ only in it and pin byte-identical artifacts on all three backends. It exists in the IR-facing contract so the writer can read it, and for no other reason.- A grouped view exports leaf rows.
rowGroupCols,valueColsandgroupKeysare discarded outright, so the compiled IR carries nogroupSpecand no aggregations and the GRP-1 dispatch is never entered.page-export/010and/011send a fully populated single- and two-level group state with aggregations, and/024adds a non-emptygroupKeys— a partially consumed path, the shape GRP-1 would otherwise dispatch to a grouped level — and all three pin flat, ungrouped artifacts with no drill-down predicate. Group-structured and pivot exports are out of scope for v1. The discard applies to either scope: the output is a flat delimited row stream either way, and the scope decides only how many rows go into it. groupKeysis discarded with the other two rather than refused, and the widening is accepted knowingly. A drill-down key restricts the result to one bucket, so dropping it exports strictly more rows than the grid is showing. That is true — and it is equally true of droppingrowGroupCols, which this same rule mandates, so it does not distinguish the three members. The case that decides it is the obvious host integration: an export request built by copying the grid's lastgetRowspayload and addingexportFormatcarries whatever drill-down path the user had expanded, and refusing it would hard-fail every export taken from an expanded grid. All three members describe one thing — the group state of the view — and EXP-1(a) discards that state.- The one genuinely incoherent combination is permitted, not refused:
exportScope: "page"over a grouped view. ThestartRow/endRowrange the grid sent was computed against grouped rows, and the export emits leaf rows, so the window is of questionable meaning — it is a count of one kind of row applied to another. It is nevertheless honoured rather than rejected, for the same reason thegroupKeysdiscard is: refusing it would break the copy-the-last-payload integration for a request the client can reasonably send. Nothing pins it, and no fixture does, deliberately — the shape has no answer worth freezing until a host asks for one.
EXP-1(b). An export names its output columns; an ordinary row query still does not. This is the widening GRP-3 deferred to "the export feature", and it is deliberately narrow — it did not become a general projection rule:
- Absent
exportColumns, the projection is every field the schema declares that isexportable, in declaration order (thefieldsobject's member order in the schema document, GRP-3's rule and for GRP-3's reason). Headers come from each field'slabel, falling back to its colId.page-export/009pins the all-exportable case and/023the case where one field is declared"exportable": falseand is absent from the projection while still being filtered on —exportableand SC-2'sfilterableare independent flags. - Present
exportColumns, the projection is exactly those columns, in request order, and theheaderstrings are the writer's alone.page-export/008names three of seven with custom headers; none of the three headers appears in any of its arms. Aheaderis arbitrary client text carried verbatim, so EXP-6's formula-injection hardening applies to the header row exactly as it applies to values: a header beginning=,+,-,@, tab or CR is prefixed with'like any cell. EXP-6's wording is about values because no header existed when it was written; the row a header lands in is a spreadsheet row like any other. It applies unconditionally here — #1652 narrowed EXP-6's scope for cells, and whatever that narrowing spares, it has nothing to exclude on this side, because a header is always text. What the narrowing is, is the TRD's EXP-6 to state and not this addendum's: the claim above is EXP-1(b)'s own (aheaderis client text), and restating the cell rule here is what would make the two drift. - A column also carries what EXP-5 declares for it, and a compiler reads none of it. A field's
format(its date pattern and decimal separator, inGridSchemaconfig since #1653) is resolved onto the column beside its header, because the writer is handed nothing else per field. It is stated here for one reason, and it is a compilation one: like alabel, aformatmust leave every compiled artifact untouched.page-export/026is/013's request, row stream and writer config byte for byte with twoformatmembers added to its schema, and pins a byte-identicalpostgres.artifact.json— the same statement/004-/005and/025make aboutexportFormat, made for the first time about a schema member. What those overrides mean and how a value renders under them is EXP-5's, in the TRD, and is deliberately not restated here. - The resolution happens once, in the request adapter, not per compiler: an unknown colId, a colId the schema declares non-exportable, a repeated colId, and an explicitly empty list are all refused there. All four are hard failures in every
GridSchemamode — Lenient's contract is that an unknown filter condition vanishes and the result merely widens, whereas a dropped export column hands back a file missing something the client asked for by name, which is the same reasoning that keeps agroupColand an aggregation field hard failures under GRP-1. - An ordinary row query is unchanged and still renders
SELECT *(and no$project, and no_sourcefilter).page-export/001-003are the category's plain-paging baseline, carry no export member at all, and are spelled exactly like every other row query in the suite. #1630 had authored their Postgres arms with an explicit column list their own Mongo arms did not have; #1650 corrected them rather than generalising the rule, because widening every row query is a decision about the grid's response shape, which no fixture in the suite pins and this feature does not own.
Per backend. On SQL the projection is the SELECT list, each column aliased back to its logical name only where the physical column differs ("order_date" AS "orderDate", but plain "status") — GRP-3's drill-down-leaf rule, reused unchanged. On MongoDB it is a trailing $project, after any $skip/$limit, re-keying a differing physical path with the expression form ("id": "$_id") and a matching one with a plain 1, then _id: 0 last (MDB-10's shape rules apply to it like any other stage document; the suppression is written after the output list because that list's order is what is normative and byte-compared). On OpenSearch/Elasticsearch there is no projection at all — see OSE-13, which is a statement about the artifact's admitted member set, and the note there on _source filtering. Column selection and ordering for that backend fall to the writer, reading exportColumns from the request it already holds. That is not EXP-1(b) contradicting OSE-13; it is one rule with a per-backend split, and the fourteen Search arms in page-export/ pin it.
EXP-2. exportScope resolves to a page mode, and nothing else in the compiler changes. "all" is $defs/nonePage — the whole filtered and sorted result, with the request's own startRow/endRow discarded, not merely absent. "page" honours that range exactly as an ordinary row fetch does. page-export/006 and /007 are the pair that pins this: identical requests down to startRow: 200, endRow: 250, differing only in the scope, and 006 compiles with no LIMIT/OFFSET, no $skip/$limit and no from/size on any backend. The startRow/endRow pair is still shape-checked before the scope overrides it — a half-supplied range is malformed whether or not this scope would have used it.
SEM-6's tiebreaker is unaffected: page: none is still a paged read as far as determinism is concerned (a stream can be resumed, and an unordered one cannot be), so the stable key is appended exactly as it always is. sort-paging/012 and every exportScope: "all" fixture in page-export/ carry it.
Cross-links. $defs/nonePage, $defs/rangePage, $defs/groupSpec, GRP-1 (the dispatch the carve-out bypasses), GRP-3 (the projection rule this one composes with), SEM-6 (the tiebreaker page: none keeps), OSE-13 and MDB-10. spec/fixtures/page-export/ is the artifact oracle, plus sort-paging/012 for the page: none shape on all three backends. EXP-3..EXP-8 — streaming and chunking, the CSV writer, its formatting and injection hardening, and the row-count limit — have no compiled form and are not restated here; the TRD §6.1 prose is their normative home. #1651 built the writer half of EXP-4/EXP-5, #1652 EXP-6's injection hardening and #1653 EXP-5's per-field format overrides, and their oracle is the byte-exact expected/export.csv/.tsv files in page-export/012-020, /022, /025 and /026 — twelve of that category's twenty-six cases, which is every writer-facing one except 021 (EXP-7's row limit produces no output to compare). See the category README for the file shapes. #1652 also narrowed EXP-6's scope, and that narrowing is stated at EXP-6 itself in the TRD — deliberately not here, and not in summary either: it turns on a distinction fine enough (which spelling of the type test, not just which types) that a second copy would be wrong within a story or two. page-export/018 is its oracle. EXP-3 and EXP-7 are the execution adapters'.