Skip to content

[core] Ignore blank values in FieldListaggAgg operator.#8480

Merged
JingsongLi merged 2 commits into
apache:masterfrom
PyRSA:feature/listagg-ignore-blank-value
Jul 7, 2026
Merged

[core] Ignore blank values in FieldListaggAgg operator.#8480
JingsongLi merged 2 commits into
apache:masterfrom
PyRSA:feature/listagg-ignore-blank-value

Conversation

@PyRSA

@PyRSA PyRSA commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Purpose

[Fix] Ignore blank input values when using field.{fieldName}.aggregate-function=listagg

Expected behavior

Case Input A Input B Current Output Expected Output
listagg 'user1,user2,user3' '' (empty string) 'user1,user2,user3,' 'user1,user2,user3'
listagg 'user1,user2,user3' ' ' (space) 'user1,user2,user3, ' 'user1,user2,user3'
listagg 'user1,user2,user3' '\t' (tab) 'user1,user2,user3,\t' 'user1,user2,user3'
listagg 'user1,user2,user3' '\n' (newline) 'user1,user2,user3,\n' 'user1,user2,user3'
listagg 'user1,user2,user3' '\r' (carriage return) 'user1,user2,user3,\r' 'user1,user2,user3'
listagg ' ' (whitespace only) 'user1,user2,user3' ' ,user1,user2,user3' 'user1,user2,user3'

Blank values are determined using org.apache.paimon.utils.StringUtils.StringUtils.isBlank(...).

Tests

  • org.apache.paimon.mergetree.compact.aggregate.FieldAggregatorTest#testFieldListAggWithDefaultDelimiterIgnoringBlankValues
  • org.apache.paimon.mergetree.compact.aggregate.FieldAggregatorTest#testFieldListAggWithDefaultDelimiterAndDistinctIgnoringBlankValues
  • org.apache.paimon.mergetree.compact.aggregate.FieldAggregatorTest#testFieldListAggFirstNonBlankValueWithoutLeadingDelimiter

@JingsongLi

Copy link
Copy Markdown
Contributor

This changes the non-distinct LISTAGG behavior when the accumulator is null. For the first non-blank value, mergeFieldSD is initialized as BinaryString.EMPTY_UTF8, and the final path returns concat(EMPTY, delimiter, input), so the result starts with the delimiter (for example ",first line"). This breaks the existing Flink ListAggAggregationITCase. Could we keep the old accumulator == null handling for non-blank inputs, and add a test for agg(null, BinaryString.fromString("first line"))?

@PyRSA

PyRSA commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

This changes the non-distinct LISTAGG behavior when the accumulator is null. For the first non-blank value, mergeFieldSD is initialized as BinaryString.EMPTY_UTF8, and the final path returns concat(EMPTY, delimiter, input), so the result starts with the delimiter (for example ",first line"). This breaks the existing Flink ListAggAggregationITCase. Could we keep the old accumulator == null handling for non-blank inputs, and add a test for agg(null, BinaryString.fromString("first line"))?

Thanks for pointing this out! I've adjusted it accordingly.

@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit 622e67d into apache:master Jul 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants