|
| 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