This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 598ff84f75 [core] Add test for retracting null fields in aggregation
merge function (#11020)
598ff84f75 is described below
commit 598ff84f75179a784e16fb74d866c9f0fd263a28
Author: chenjian2664 <[email protected]>
AuthorDate: Tue Nov 10 17:15:22 2026 +0800
[core] Add test for retracting null fields in aggregation merge function
(#11020)
---
.../aggregate/AggregateMergeFunctionTest.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git
a/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/aggregate/AggregateMergeFunctionTest.java
b/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/aggregate/AggregateMergeFunctionTest.java
index f1ae731511..a6b86884f4 100644
---
a/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/aggregate/AggregateMergeFunctionTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/mergetree/compact/aggregate/AggregateMergeFunctionTest.java
@@ -171,6 +171,37 @@ class AggregateMergeFunctionTest {
assertThat(aggregateFunction.getResult().value()).isEqualTo(GenericRow.of(1, 2,
2, null));
}
+ @Test
+ void testRetractNullFieldKeepsAccumulator() {
+ Options options = new Options();
+ options.set("fields.a.aggregate-function", "sum");
+ options.set("fields.b.aggregate-function", "product");
+ options.set("fields.c.aggregate-function", "last_non_null_value");
+ options.set("fields.d.aggregate-function", "sum");
+ MergeFunction<KeyValue> aggregateFunction =
+ AggregateMergeFunction.factory(
+ options,
+ RowType.builder()
+ .fields(
+ new DataType[] {
+ DataTypes.INT(),
+ DataTypes.INT(),
+ DataTypes.INT(),
+ DataTypes.INT(),
+ DataTypes.INT()
+ },
+ new String[] {"k", "a", "b",
"c", "d"})
+ .build(),
+ Collections.singletonList("k"))
+ .create();
+ aggregateFunction.reset();
+
+ aggregateFunction.add(value(1, 5, 5, 5, 5));
+ // retracting a null field must not change its accumulated value
+ aggregateFunction.add(deleteValue(1, null, null, null, 2));
+
assertThat(aggregateFunction.getResult().value()).isEqualTo(GenericRow.of(1, 5,
5, 5, 3));
+ }
+
private KeyValue value(Integer... values) {
return new KeyValue()
.replace(GenericRow.of(values[0]), RowKind.INSERT,
GenericRow.of(values));