← Back to Pull requests

[core] Gather merged aggregation rows from their inputs instead of one-row batches #1440

Closed
unknown closed this pull request without merging on Nov 22, 2026 04:49 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 14:46 UTC
Author

Purpose

Linked issue: part of #1336, follows #1420

Aggregation reads still build a one-row RecordBatch for every merged key: merge_ordered slices the key columns, adds one-row metadata arrays and wraps them with the aggregator results, and the reader then interleaves those batches. #1420 removed this for partial-update.

Brief change log

  • AggregateMergeFunction implements merge_picked. A live merged row is returned as its key row plus each aggregator's result, without building a batch. The reader gathers key columns with interleave as for partial-update, and concatenates each aggregated column once per output batch. Aggregated values are kept by output column so assembly stays linear in projection width.

  • Deleted rows, lone versions and other merge functions keep the existing merge path, as does the write buffer.
  • PK table, 2M keys written 3 times, sum and last_non_null_value, full read, in-memory FileIO, release build. Measured in one binary with merge_picked switched off by an env var, over 3 alternating rounds:

  • every round writes both value columns: 1955–1988 → 1588–1626 ms

  • rounds write different columns: 1921–1936 → 1562–1579 ms

  • 256 INT sum columns, 100k keys written twice: 9509–9933 → 9124–9314 ms

  • 32 INT sum columns, 500k keys written twice: 4720–4850 → 4514–4591 ms
  • What remains is mostly the aggregators' one-row results. Avoiding those would need the builder change discussed in #1336.

    Tests

  • test_aggregate_picked_rows_match_materialized_rows: three overlapping runs with sum and last_non_null_value, a key removed by DELETE under aggregation.remove-record-on-delete, an all-NULL sum, lone keys and batch size 2. It reads them once through merge_picked and once through a wrapper that only has merge, and checks that the batches are equal and the values are as expected. Dropping the aggregator results from the picked row fails it, along with four existing aggregation tests.
  • Ran the ci.yml steps locally (fmt, clippy, msrv, unit, rest-server, integration, datafusion, python, go).

    API and Format

    None.

    Documentation

    None.

    Diff: 270 lines (+202 / -68) across 3 files Reviewer: JeonDaehong Review duration: 6602m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 270 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.335
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1440"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.6% · Safe to merge
    15.6%