[feature](function) Add array_agg_if aggregate function - #67534
Open
yujun777 wants to merge 2 commits into
Open
Conversation
Support conditional array aggregation: rows whose condition is false or NULL are skipped entirely; remaining rows are collected with array_agg semantics, so NULL elements are kept. Key changes: - BE: implement array_agg_if(cond, elem) reusing the array_agg state template, parameterized by element argument index and input nullability, so the per-row add() path keeps zero-cost asserts - BE: handle raw (non-nullable) complex element types in the native serde state output/deserialize paths - FE: add ArrayAggIf aggregate expression class with cond-first signature and register it in the builtin aggregate catalog - regression: add three array_agg_if queries to the agg suite with generated expected output Unit Test: - agg_array_agg_if_test: 9 cases covering cond filtering, NULL element retention, NULL cond, and string/complex (nullable and NOT NULL) element types, each exercised through single-add, merge and serialize/deserialize paths - agg_array_agg_test regression: 9 existing array_agg cases - end-to-end: array_agg_if queries verified against the generated agg.out on a local cluster
yujun777
requested review from
924060929,
englefly,
morrySnow and
starocean999
as code owners
September 4, 2026 11:18
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 17129 ms |
Contributor
TPC-DS: Total hot run time: 82762 ms |
Contributor
ClickBench: Total hot run time: 14.72 s |
…al append The three array_agg_if blocks were manually appended to agg.out with an extra blank line, which made the block parser read one extra empty row for the preceding sql_array_agg_not_nullable block and fail the suite. Restore the single-blank-line block separator; the appended content itself matches the framework-generated output. Unit Test: - nereids_function_p0 agg_function suite passes in comparison mode
Contributor
Author
|
run buildall |
Contributor
TPC-H: Total hot run time: 16833 ms |
Contributor
TPC-DS: Total hot run time: 83042 ms |
Contributor
ClickBench: Total hot run time: 14.75 s |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
Author
|
run cloud_p0 |
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
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.
Support conditional array aggregation: rows whose condition is false or NULL are skipped entirely; remaining rows are collected with
array_aggsemantics, so NULL elements are kept. Returns an empty array when no row matches.Docs: apache/doris-website#4117
Key changes:
array_agg_if(cond, elem)reusing thearray_aggstate template, parameterized by element argument index and input nullability, so the per-rowadd()path keeps zero-cost assertsArrayAggIfaggregate expression class with cond-first signature and register it in the builtin aggregate catalogarray_agg_ifqueries to the agg suite with generated expected outputUnit Test:
agg_array_agg_if_test: 9 cases covering cond filtering, NULL element retention, NULL cond, and string/complex (nullable and NOT NULL) element types, each exercised through single-add, merge and serialize/deserialize pathsagg_array_agg_testregression: 9 existing array_agg casesarray_agg_ifqueries verified against the generatedagg.outon a local cluster