← Back to Pull requests

[core] Do not count a retracted partial-update sum twice #1549

Open
unknown opened this pull request with 258 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 25, 2026 12:59 UTC
Author

Purpose

Closes #1543.

With a sequence group and a sum aggregate, a merge that starts with a retraction seeded the row from the retracted record, so the retraction cancelled its own payload and the old value was counted again. +I(90) and then -U(90), +U(90) read 180. This follows apache/paimon#11274, which fixes the same behavior in Java.

Brief change log

  • Under sequence groups without ignore-delete, a merge that starts with a retraction seeds only the required fields. A required sum starts at zero and nullable fields stay NULL.

  • A result made only of retractions emits each aggregate through retraction_result. For sum it flips the sign, so a later merge that retracts it again subtracts the right amount.

  • Other aggregates keep their current behavior, as in Java.
  • Tests

    pk_partial_update_first_retract_test covers a retraction and an update in one commit, a retraction-only commit before an update, and a required sum whose sequence group is skipped. The first two also read again after a compaction. All three fail on main.

    Two existing tests pinned the old seeding and now expect what Java returns with apache/paimon#11274 (checked on that branch merged with master):

  • partial_update_retract_only_aggregate_state_refuses_lossy_compaction: -D(10), -D(5), +I(3) on a summed field read -2, which is the double count itself. It now reads -12.

  • partial_update_ignore_retract_first_value_preserves_uninitialized_state: -D(version 3, 20) then +I(version 2, 5) on an ignore-retract first_value read (3, 20). The DELETE no longer seeds the value, so it reads (3, NULL).
  • I also wrote random +I/+U/-U/-D sequences on one key and split them into commits in different ways, with and without full compactions, covering nullable and required sums, ignore-delete, null sequence values and amounts, and the lookup changelog producer. Main read the wrong sum for 326 of 1,400 sequences, this branch for none of 2,100.

    API and Format

    No public API or storage format changes.

    Documentation

    None.

    Diff: 258 lines (+193 / -65) across 3 files Reviewer: JeonDaehong Review duration: 8136m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 258 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #1549"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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.2% (MEDIUM) · Higher = larger blast radius
    39.2%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 20.9% · Safe to merge
    20.9%