Repository navigation
[docs] Clarify FIRST_VALUE null handling in aggregation - #4946
Conversation
Keep the existing field value even when it is null. The row merger already handles the first write before invoking field aggregation. Cover null first values across full and partial updates.
Start with no existing row and verify that 10 is retained across subsequent inputs 20, null, and 30 for full and partial updates.
|
@platinumhamburg, I think this breaks a more common case: with partial updates, a column that wasn't written yet also reaches I used a test: a partial write of Since "first value was null" and "not written yet" can't be told apart without extra state per field, should we keep the current behavior and update the docs to say |
|
@polyzos Thanks for catching this. You’re right: I overlooked the distinction between the first write to a row and the first write to an individual field. The added partial-update tests always included the Given that both “not written yet” and “explicitly written as NULL” are represented by a null accumulator, preserving the existing partial-update behavior is the better tradeoff. I agree we should keep the current implementation and document that This means accepting a semantic difference from Paimon until we have a practical way to preserve that distinction across writes and recovery. I’ll update the issue and rework this PR as a documentation correction. |
Document FIRST_VALUE as retaining the first non-null value, matching FIRST_VALUE_IGNORE_NULLS. Preserve partial-update initialization by keeping the existing aggregation implementation.
Purpose
Fixes #4945.
The aggregation documentation and
AggFunctions.FIRST_VALUE()Javadoc promise that an initial NULL is retained, but the implementation treats NULL as unset and keeps the first non-null value. For example,NULL -> 10 -> 20produces10.Document this existing behavior so that fields omitted from an initial partial update can still receive their first non-null value in a later update. An unset field and an explicitly written NULL share the same null accumulator.
Brief change log
FIRST_VALUEas retaining the first non-null value in the user documentation and API Javadoc.FIRST_VALUE_IGNORE_NULLS.Tests
Passed on JDK 11:
Includes the existing aggregation tests, Spotless, Checkstyle, and license checks. The complete repository test suite was not run.
API and Format
No runtime behavior, API signature, or storage format changes. The Javadoc now describes the existing NULL handling.
Documentation
Update the aggregation merge engine's
first_valuesection andAggFunctions.FIRST_VALUE()Javadoc.