fix(rust): render columns in projection order - #1171
Merged
Merged
Conversation
skip-changelog: test-only commit
Thread the statement's column order out of the query path and serialize each row against it, instead of re-deriving the column set from the unordered row maps.
8 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1170
SELECT path, ctime FROM './'printedctime, path:Db::querycollected eachrow into a
HashMapand threw awaystmt.column_names(), so every rendererre-derived its columns from row keys and got alphabetical order.
--format jsonhad the same defect through
serde_json's BTreeMap-backed objects.The column order now travels with the rows.
Db::query_ordered/DirSQL::query_orderedreturn aQueryResult { columns, rows }; the CLI'sshared query pipeline serializes each row against
columns(withserde_json'spreserve_order), and the table renderer takes the columns inthe order the rows carry them rather than sorting them into a
BTreeSet.querykeeps itsVec<Row>signature, soRow,differ.rsand the SDKbindings are untouched.
Scope is the Rust core + CLI. Python/TS parity is drift, tracked in
PARITY.mdand filed as #1173 and #1174.
Red/green
The two test commits went up alone first. CI (Rust CI / Integration tests, run
35888793774) went red on the new integration test for exactly the asserted
reason:
cargo testaborts at the first failing test binary, socolumn_order_e2e.rswas not reached in that run; its red was confirmed locally on the same commit:
Manual run
Built
cargo build -p dirsql --features cliand ran it over a two-file temp dir:E2E Verification
packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts)cargo test --manifest-path packages/rust/Cargo.toml --features cli --lib,... --tests,just e2e-attest-python,just e2e-attest-ts,just preflightChangelog / Migrations
<root>/<pkg>/changelog.d/for each changed package (packages/rust/changelog.d/2026-09-23-projection-column-order.md)<root>/<pkg>/migrations.d/(packages/rust/migrations.d/2026-09-23-projection-column-order.md— output key order changes for consumers who relied on the alphabetical order)Parity
Introduces drift:
query_ordered/QueryResultexist in Rust only.PARITY.mdupdated; follow-ups filed as #1173 (Python) and #1174 (TypeScript).