fix(aggregate): preserve listagg result ownership - #281
Merged
lxy-9602 merged 4 commits intoSep 4, 2026
Conversation
lxy-9602
reviewed
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: N/A
FieldListaggAggreturned astd::string_viewbacked by a mutable member string shared by all calls to the same aggregator instance.The merge path reuses one field aggregator across primary keys, while
SortMergeReaderBatchProducermay retain results for multiple keys before converting the batch to Arrow. As a result, aggregating a later key could overwrite or invalidate the string data referenced by an earlier key, causing cross-key data corruption.This change:
BinaryString;Tests
Added:
FieldListaggAggTest.TestResultOwnershipAcrossAggregationsfor the aggregator result-lifetime contract;WriteAndReadInteTest.TestPKListAggPreservesResultsAcrossKeysfor the real PK merge path inwrite_and_read_inte_test.cpp.The integration test creates a PK aggregation table, writes two keys over two commits, and verifies that each key retains its independently accumulated
listaggvalue.Before the production fix, the integration test fails deterministically for all three enabled formats (Parquet, ORC, and Avro):
After the fix:
paimon-write-and-read-inte-testbuilds successfully;TestPKListAggPreservesResultsAcrossKeys: 3/3 format variants passed;TestPKSimple: 3/3 format variants passed;paimon-core-testbuilds and links successfully on macOS arm64 after replacing the non-portable BIGINT test literals;git diff --checkpassed.The focused
FieldListaggAggTest.*execution is still blocked in this local build by an existing macOS static/shared plugin registration issue (Could not find a FileFormatFactory implementation class for format 'parquet'). This does not affect the integration-test target above.API and Format
No public API, storage format, or protocol changes.
Documentation
No documentation changes are required.
Generative AI tooling
Generated-by: OpenAI Codex (GPT-5)