You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/04/16 15:39:41 UTC

(datafusion) 01/01: chore: Add more tests with `GROUP BY` to test spark `collect_set` (#21659)

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch gh-readonly-queue/main/pr-21659-2ef021770598b723210f81d16c897fd98dab7771
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit 87772515f5c26e9915b197a5a4d7c83023d0715c
Author: Oleks V <co...@users.noreply.github.com>
AuthorDate: Thu Apr 16 08:39:18 2026 -0700

    chore: Add more tests with `GROUP BY` to test spark `collect_set` (#21659)
    
    ## Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax. For example
    `Closes #123` indicates that this PR will close issue #123.
    -->
    
    - Closes #.
    
    ## Rationale for this change
    
    `collect_set` is aggregate function, adding more tests with GROUP BY
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    
    ## What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    ## Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    -->
    
    ## Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    -->
    
    <!--
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
    
    ---------
    
    Co-authored-by: Martin Grigorov <ma...@users.noreply.github.com>
---
 .../test_files/spark/aggregate/collect.slt         | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/datafusion/sqllogictest/test_files/spark/aggregate/collect.slt b/datafusion/sqllogictest/test_files/spark/aggregate/collect.slt
index 2bd80e2e13..c367c9cb7a 100644
--- a/datafusion/sqllogictest/test_files/spark/aggregate/collect.slt
+++ b/datafusion/sqllogictest/test_files/spark/aggregate/collect.slt
@@ -91,3 +91,34 @@ ORDER BY g;
 ----
 1 [10]
 2 [20]
+
+# collect_set with GROUP BY: group where all values are NULL returns empty list
+query I?
+SELECT g, array_sort(collect_set(a))
+FROM (VALUES (1::INT, 10::INT), (1::INT, 20::INT), (2::INT, NULL::INT), (2::INT, NULL::INT)) AS t(g, a)
+GROUP BY g
+ORDER BY g;
+----
+1 [10, 20]
+2 []
+
+# collect_set with GROUP BY: string values with duplicates
+query T?
+SELECT g, array_sort(collect_set(v))
+FROM (VALUES ('a'::TEXT, 'x'::TEXT), ('a'::TEXT, 'y'::TEXT), ('a'::TEXT, 'x'::TEXT), ('b'::TEXT, 'z'::TEXT), ('b'::TEXT, 'z'::TEXT)) AS t(g, v)
+GROUP BY g
+ORDER BY g;
+----
+a [x, y]
+b [z]
+
+# collect_set with GROUP BY: multiple groups with mixed NULLs and duplicates
+query I?
+SELECT g, array_sort(collect_set(a))
+FROM (VALUES (1::INT, 5::INT), (1::INT, 5::INT), (1::INT, NULL::INT), (2::INT, 10::INT), (2::INT, 20::INT), (2::INT, 10::INT), (3::INT, NULL::INT), (3::INT, NULL::INT)) AS t(g, a)
+GROUP BY g
+ORDER BY g;
+----
+1 [5]
+2 [10, 20]
+3 []


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org