Skip to content

Commit 067ba4b

Browse files
authored
chore: add aggregation test for listview types (apache#21776)
## 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 apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#19782 ## Rationale for this change <!-- 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. --> We've landed various PRs required to support aggregating on list views (both upstream in arrow-rs and here in datafusion) so now this simple aggregation test succeeds; adding it to the slt suite. ## 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. --> Add aggregation test for listviews ## 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)? --> Yes ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> No <!-- If there are any breaking changes to public APIs, please add the `api change` label. -->
1 parent 9d73d09 commit 067ba4b

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
#############
19+
## ListView Aggregation Tests
20+
#############
21+
22+
### Setup: Create test tables with ListView arrays
23+
24+
statement ok
25+
CREATE TABLE list_view_agg_test AS
26+
SELECT
27+
id,
28+
group_col,
29+
arrow_cast(make_array(val1, val2, val3), 'ListView(Int64)') as list_view_col,
30+
arrow_cast(make_array(val1, val2, val3), 'LargeListView(Int64)') as large_list_view_col
31+
FROM (VALUES
32+
(1, 'A', 10, 20, 30),
33+
(2, 'A', 40, 50, 60),
34+
(3, 'B', 70, 80, 90),
35+
(4, 'B', 100, 110, 120),
36+
(5, 'C', 1, 2, 3)
37+
) AS t(id, group_col, val1, val2, val3);
38+
39+
### Test: GROUP BY on ListView column
40+
41+
query ?I rowsort
42+
SELECT list_view_col, COUNT(*)
43+
FROM list_view_agg_test
44+
GROUP BY list_view_col;
45+
----
46+
[1, 2, 3] 1
47+
[10, 20, 30] 1
48+
[100, 110, 120] 1
49+
[40, 50, 60] 1
50+
[70, 80, 90] 1
51+
52+
query ?I rowsort
53+
SELECT large_list_view_col, COUNT(*)
54+
FROM list_view_agg_test
55+
GROUP BY large_list_view_col;
56+
----
57+
[1, 2, 3] 1
58+
[10, 20, 30] 1
59+
[100, 110, 120] 1
60+
[40, 50, 60] 1
61+
[70, 80, 90] 1
62+
63+
### Cleanup
64+
65+
statement ok
66+
DROP TABLE list_view_agg_test;

0 commit comments

Comments
 (0)