Repository navigation
fix(query): route weight/cost(position) over #postings to the posting - #2431
Conversation
`#postings` materializes its rows as values, so `weight(position)` and
`cost(position)` there answered from the Position: a priced posting
weighed its units, and a `{{T}}` lot cost units x the rounded per-unit
cost. The default FROM reads the posting for both (#1966, #2425).
The table now computes both from the posting into two hidden
NUL-named columns, which `SELECT *` does not show, and the row
evaluator routes the two calls there when the column is present. A
subquery with its own `position` column carries no hidden column and
keeps the value path.
Closes #2429
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…eads it `#postings` computes every row's `cost(position)` up front, and raised its overflow while building the table, so one lot whose cost overflows failed every `#postings` query, `SELECT account` included. The default FROM computes it only when asked. The table now keeps the error in a hidden column, and the route raises it when a query reads that row's `cost(position)`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr
Deep reviewFixed in 3abe5ce: an overflowing lot failed every
|
What
weight(position)andcost(position)overFROM #postingsnow match the default FROM on every posting.Both functions need the posting itself.
weightranks a price ahead of a cost, and a{{T}}lot's cost is its total. APositionvalue carries neither. The default FROM already reads the posting (#1966, #2428).#postingsbuilds its rows as values, so it answered from thePositioninstead:#postingsweight(position)of10 EUR @ 1.10 USD10 EUR11.00 USD(itsweightcolumn)cost(position)of3 X {{500 USD}}500.0000000000000000000000001500How
build_postings_tablecomputes both values per posting into two hidden columns:compute_posting_weight, the canonicalcost_number_weightpath;compute_posting_cost, falling back to the value path as the default FROM does.Table::with_hiddenkeeps them out ofSELECT *.cost(position)overflow, raised only when a query reads that row'scost(position). The default FROM also computes it lazily, so one overflowing lot doesn't failSELECT account FROM #postings.evaluate_subquery_exprroutesWEIGHT(position)andCOST(position)to these columns only when the column exists. A subquery that aliases something else aspositionhas no hidden column, so it keeps the value path.Tests
crates/rustledger-query/tests/postings_table_matches_default_from.rs:{{T}}/ per-unit ledger returns identicalweight,weight(position)andcost(position)under both FROM clauses, withweight == weight(position). With the route disabled, this test fails.SELECT *shows no hidden column.units(position) AS positionstill gets10 EUR.cost(position), under both FROM clauses.Checks
cargo clippy --workspace --all-features --all-targets -D warnings: clean.rustledger-query753 passed at 3abe5ce.cargo mutants --in-diff: 3 caught, 5 unviable, 0 missed.Docs
docs/reference/bql.mdand CHANGELOG.#postingsas a per-unit exception.cost(sum(position))remains one (BQL: cost(sum(position)) multiplies the rounded per-unit cost back out (500.00…01 for a {{500 USD}} lot) #2430).Closes #2429
🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr