Skip to content

test: cover array_agg(DISTINCT) on dictionaries and bounded retract_batch memory#23873

Open
alamb wants to merge 2 commits into
apache:mainfrom
alamb:test/array_agg_distinct_coverage
Open

test: cover array_agg(DISTINCT) on dictionaries and bounded retract_batch memory#23873
alamb wants to merge 2 commits into
apache:mainfrom
alamb:test/array_agg_distinct_coverage

Conversation

@alamb

@alamb alamb commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

It adds test coverage for two gaps found while reviewing #23716.

What changes are included in this PR?

Tests only, no functional change.

  • Dictionary inputs
  • memory usage on retract (make sure memory is released)

Note I moved array_agg cases out aggregate.slt as it is already more than 9k lines long

Are these changes tested?

They are only tests

Are there any user-facing changes?

No. Tests only, no public API changes.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Jul 24, 2026
@alamb
alamb force-pushed the test/array_agg_distinct_coverage branch from 5da1f62 to 79fc2c4 Compare July 24, 2026 20:29
… memory

Adds two pieces of coverage for `DistinctArrayAggAccumulator` that are
missing today:

1. `array_agg(DISTINCT ...)` over a dictionary encoded column. There is
   currently no test anywhere that aggregates a dictionary with DISTINCT,
   so nothing pins the requirement that the returned list keeps its
   declared `List(Dictionary(..))` element type. Covers the plain,
   nested-in-a-struct and zero-input cases.

2. A `retract_batch` test asserting that `size()` does not grow with the
   number of rows that have passed through the accumulator. The existing
   sliding window cases in `array_agg_sliding_window.slt` use five row
   tables, which is too small to notice an accumulator that never
   reclaims retracted values.

Both tests pass on main and describe behavior that is already correct.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@alamb
alamb force-pushed the test/array_agg_distinct_coverage branch from 79fc2c4 to f6fa5cf Compare July 24, 2026 20:33
@codecov-commenter

codecov-commenter commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.18182% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.70%. Comparing base (0d8482c) to head (9069c0d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/functions-aggregate/src/array_agg.rs 68.18% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23873      +/-   ##
==========================================
- Coverage   80.71%   80.70%   -0.02%     
==========================================
  Files        1090     1090              
  Lines      370370   370358      -12     
  Branches   370370   370358      -12     
==========================================
- Hits       298954   298887      -67     
- Misses      53595    53648      +53     
- Partials    17821    17823       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

OVER (ROWS BETWEEN 4 PRECEDING AND CURRENT ROW)
FROM aggregate_test_100

# array agg can use order by

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these tests verbatim to datafusion/sqllogictest/test_files/array_agg.slt and added several new ones at the end


query error Error during planning: ORDER BY and WITHIN GROUP clauses cannot be used together in the same aggregate function
SELECT array_agg(a_varchar order by a_varchar) WITHIN GROUP (ORDER BY a_varchar)
FROM (VALUES ('a'), ('d'), ('c'), ('a')) t(a_varchar);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Coverage starts here

@alamb
alamb marked this pull request as ready for review July 24, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants