[pull] master from GaijinEntertainment:master#1031
Merged
Conversation
…dit doc Closes Theme 1 from the linq_fold chain audit (benchmarks/sql/linq_fold_chain_audit.md) — splices the natural "produce K items, project to a field" idiom across 5 arms that previously fell off to the default cascade. - plan_order_family / plan_decs_order_family: accept terminal _select after take(N). Bounded-heap holds raw element so cmp sees source type; projection runs ≤K times at return. Closes the motivating closest-sounds case + audit rows 1a, 1e. - plan_reverse / plan_decs_reverse: accept terminal _select after reverse[+take]. R1-R4 buffer projects at return; first/first_or_default applies projection to the surviving `last` value. Skip-into-tail fast path defers when projection set. Closes "filter, reverse for newest-first, take K, project" idiom. - plan_decs_join: accept single trailing _select between _join and terminator. Per-pair work becomes one bind + one projected push (no intermediate buffer). Closes audit row 8b. - plan_zip: pre-lower 3-arg zip(a, b, sel) into the chain's `projection` slot. The dot-product idiom (`zip(b, $(x,y) => x*y) |> sum()`) now splices instead of bailing on the 3-arg shape. Closes audit row 7a. Tests: tests/linq/test_linq_fold_terminal_select.das adds 10 cases covering each extended surface. Full linq+decs+dasSQLITE suite: 2456 tests, all pass. Audit doc: benchmarks/sql/linq_fold_chain_audit.md catalogs the splice machinery silent-fall-off surface (8 chains × 3-6 probes each + 6 composition probes + 8 cross-cutting themes). Theme 1 lands with this PR; themes 2-8 queued. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Re-run INTERP + JIT across benchmarks/sql/ for the terminal-_select extension PR. Existing bench shapes don't exercise the new splice surfaces (the audit's gap was chains the benches didn't probe), so numbers match prior results within noise. Living-doc policy refresh per [[feedback-living-results-md]]. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…xts regardless of selectLam Copilot review (PR #2851): when terminal `_select` was being accepted, the bail check at plan_decs_join only required `expr._type.isGoodArrayType` in the `selectLam == null` branch. The emission below always returns `array<elemType>`, so an iterator-typed outer context would have produced an `invoke($() : iterator<T> { ...; return <- bufArray; })` type mismatch. In practice the case is currently user-unreachable — `_select` after `_join` cannot infer its `result_selector` without a downstream terminator, so the typer rejects the input upstream — but the splice should still cascade cleanly rather than emitting half-formed code on partial-type inputs. Drop `selectLam == null` from the clause; comment explains the constraint. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…erminal-select linq_fold: terminal _select extension + chain audit doc (Theme 1 of 8)
…plan_group_by_core + plan_loop_or_count
Closes 5 audit probes from `benchmarks/sql/linq_fold_chain_audit.md`
(4a, 4e, 5c, 8a, C6). Mirrors the Theme 1 cadence — same single-PR
shape, 3 splice arms extended, 12 new tests.
## plan_decs_join (closes 8a, C6)
Pop a single trailing `_where` between the join and the terminator.
Bind join result once per matched pair, gate count++/push on the
predicate. Composes cleanly with the terminal `_select` from Theme 1
(8a + 8b together: filter then project, single per-pair bind).
## plan_group_by_core (closes 4a, 4e)
Pop a single trailing `_where` AFTER `_select(reducer)` — the SQL
HAVING shape on the post-aggregate tuple. Predicate references the
constructed output by name (e.g. `_.Total > 1000`). Threaded through
both array (`plan_group_by`) and decs (`plan_decs_group_by`) entries
via the shared core. Distinct from the existing `having_` slot (which
sits between group_by_lazy and select and can lift hidden reducer
slots); both gates can fire on the same chain.
`outputExpr` / `bufElemType` computation lifted out of the to_array
branch so the count branch can also bind + predicate-gate when a
trailing `_where` is present.
## plan_loop_or_count (closes 5c)
`take(N)._where(p).terminator` — accepted across all 4 lanes
(counter / accumulator / early-exit / array). Take cap ticks
unconditionally per element; the trailing `_where` (routed to a new
`postTakeWhereCond` slot) gates only the per-element contribution.
This preserves the "first N elements, then keep matching" semantic
that `_where.take` (existing path) cannot express.
Other prior range ops (skip, skip_while, take_while) still bail
through — they're semantically subtler and sized as a follow-up. Single
post-take where in v1.
## Pitfalls
- Multi-line `wrap_with_condition(qmacro_expr() { ... }, postTakeWhereCond)`
trips a parse error; use an intermediate var.
- The iterator-context `_select` after `_join` remains user-unreachable
per Theme 1's defensive guard. Adding trailing `_where` doesn't change
this — the type inference issue lives upstream of the splice.
## Tests / coverage
- `tests/linq/test_linq_fold_theme2_trailing_where.das` — 12 new tests
covering all 3 surfaces (decs_join, group_by array+decs, take.where
across 4 lanes).
- Full suite: 1437 linq + 245 decs + 796 dasSQLITE = 2478 tests, green.
- Lint: clean on touched files.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…mit hash) INTERP + JIT re-run on `4b13eed9a`. Numbers match prior results within noise — existing bench shapes don't yet exercise the new trailing-`_where` splice surfaces (gap is the same as Theme 1: chains benches don't probe HAVING / take-then-where idioms). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tter Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR #2852 Copilot R1 — `selectElemType` was a leftover local from the Theme 1 PR that survived into Theme 2. Element type for the buffer is already derived from `expr._type.firstType` (via `resultType`); the trailing-`_select` peel only needs the lambda itself, not its return type. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…2851 + #2852 The patterns reference page had drifted three PRs out of date — the audit doc cross-checks against this page, and users reading the catalog were getting promises the macro couldn't keep. Added rows for: - **Array-source patterns**: terminal `_select` on `_order_by.take` / `.reverse.take` (Theme 1); `take(N)._where(P)` across 4 lanes (Theme 2); post-aggregate HAVING via trailing `_where` after `_group_by._select(reducer)` (Theme 2). - **Decs-source patterns**: same terminal-`_select` mirrors on the decs side. - **Decs-decs equi-join** (NEW subsection): the four chain shapes `plan_decs_join` accepts — `_join + count`, `+ to_array`, `+ _select(F) + to_array` (Theme 1), `+ _where(P) + count / to_array` (Theme 2). Updated: - Zip source row: clarified 3-arg `zip(a, b, sel)` is pre-lowered to 2-arg `zip(a, b) |> _select(sel-as-tuple)`. - HAVING row: distinguished the existing `_having(P)` slot (pre-aggregate, can lift hidden reducers) from the new trailing `_where` (post-aggregate output filter). - "What falls back" join bullet: rewrote to reflect that decs-decs primitive-key `_join` now splices; other join shapes still cascade. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…heme2-trailing-where linq_fold: Theme 2 — trailing _where extension across 3 splice arms
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )