fix(core): align collect aggregation with Java FieldCollectAgg #1352
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 343 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.349
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1352"
general
weight: 0.35
LuciferYang
Purpose
Linked issue: close #1351
collectignoredfields.<col>.count-limit, mergedaggReversedin a different order from Java master, and checkeddistinctmembership with a linear scan. This ports the merge logic of JavaFieldCollectAggas of apache/paimon#10540 and apache/paimon#10607.Brief change log
agg(accumulator, accumulatorHasDuplicate, input, inputHasDuplicate), includingcheckDuplicateUntiland backwards collection for negative limits. A DELETE value is kept as it is until the next merge.count-limitis read as a 32-bit integer, like Java'sintTypeoption.agg_reversedto the wrapped function, as Java does.needsEqualiseron the Paimon type. Deciding by Arrow type put VARIANT, BLOB and VECTOR on the wrong path.LinkedHashSetuse arrow-row keys in a hash set.VecDeque, so a late update throughagg_reversedprepends instead of rebuilding the array, except for distinct equaliser element types with a negative limit.Tests
count_limit_matches_java_for_scalar_and_row_elements: the cases of JavatestFieldCollectAggWithCountLimit, forward and reversed.agg_reversed_puts_older_input_first,ignore_retract_reversed_: reversed order, with and without the wrapper.delete_value_,agg_reversed_keeps_duplicates_of_a_binary_delete_value: DELETE values per Java element type.distinct_*_like_java: NaN payloads, signed zero and map entry order for scalar, ROW, ARRAY and MAP elements, including retract.Benchmarks (release build, in-memory FileIO): writing 20,000 single-element rows for one key with
distinct=truetakes 5.6 ms (8.7 s on main). 20,000 single-elementagg_reversedcalls, as a sequence group makes for late updates, take 1.6 ms withoutdistinct(1.5 ms on main) and 6.4 ms with distinct INT elements (4.4 s on main). Distinct ROW elements still compare each update with the collected elements, as Java's equaliser does.About 717k random steps generated by Java master's
FieldCollectAggmatch Rust on every step, covering INT, ROW, BYTES, DOUBLE with NaN, MAP, andARRAY<ARRAY<MAP>>with binary inputs.API and Format
No API or storage format change. Tables that set
count-limiton acollectcolumn now get capped arrays when Rust merges them. Maps nested in arrays match by key, as Java does since apache/paimon#11110.Documentation
docs/src/sql.mddocumentscount-limitforcollect.Generated-by: Claude Opus