@@ -101,56 +101,56 @@ select s, sum(value) from groupagg group by s order by s nulls first limit 10;
101
101
102
102
reset timescaledb.debug_require_vector_agg;
103
103
-- More tests for dictionary encoding.
104
- create table text_table(ts int);
104
+ create table text_table(ts int, a text );
105
105
select create_hypertable('text_table', 'ts', chunk_time_interval => 3);
106
106
create_hypertable
107
107
-------------------------
108
108
(3,public,text_table,t)
109
109
(1 row)
110
110
111
- alter table text_table set (timescaledb.compress);
112
- insert into text_table select 0 /*, default */ from generate_series(1, 1000) x;
111
+ alter table text_table set (timescaledb.compress, timescaledb.compress_segmentby = 'a' );
112
+ insert into text_table select -1, 'scalar' from generate_series(1, 1000) x;
113
113
select count(compress_chunk(x)) from show_chunks('text_table') x;
114
114
count
115
115
-------
116
116
1
117
117
(1 row)
118
118
119
- alter table text_table add column a text collate "POSIX" default 'default';
120
- alter table text_table set (timescaledb.compress,
121
- timescaledb.compress_segmentby = '', timescaledb.compress_orderby = 'a');
122
119
insert into text_table select 1, '' from generate_series(1, 1000) x;
123
120
insert into text_table select 2, 'same' from generate_series(1, 1000) x;
124
121
insert into text_table select 3, 'different' || x from generate_series(1, 1000) x;
125
122
insert into text_table select 4, case when x % 2 = 0 then null else 'same-with-nulls' end from generate_series(1, 1000) x;
126
123
insert into text_table select 5, case when x % 2 = 0 then null else 'different-with-nulls' || x end from generate_series(1, 1000) x;
124
+ alter table text_table set (timescaledb.compress,
125
+ timescaledb.compress_segmentby = '', timescaledb.compress_orderby = 'a');
127
126
select count(compress_chunk(x)) from show_chunks('text_table') x;
127
+ NOTICE: chunk "_hyper_3_7_chunk" is already converted to columnstore
128
128
count
129
129
-------
130
- 2
130
+ 3
131
131
(1 row)
132
132
133
133
vacuum analyze text_table;
134
134
set timescaledb.debug_require_vector_agg to 'require';
135
- select a, count(*) from text_table group by a order by a limit 10;
135
+ select a, count(*) from text_table group by a order by count(*) desc, a limit 10;
136
136
a | count
137
137
-------------------------+-------
138
138
| 1000
139
- default | 1000
139
+ same | 1000
140
+ scalar | 1000
141
+ $ | 1000
142
+ same-with-nulls | 500
140
143
different-with-nulls1 | 1
141
144
different-with-nulls101 | 1
142
145
different-with-nulls103 | 1
143
146
different-with-nulls105 | 1
144
147
different-with-nulls107 | 1
145
- different-with-nulls109 | 1
146
- different-with-nulls11 | 1
147
- different-with-nulls111 | 1
148
148
(10 rows)
149
149
150
150
-- The hash grouping policies do not support the GroupAggregate mode in the
151
- -- reverse order.
151
+ -- reverse order. We have to filter out the chunk where 'a' is segmentby.
152
152
set timescaledb.debug_require_vector_agg to 'forbid';
153
- select a, count(*) from text_table group by a order by a desc limit 10;
153
+ select a, count(*) from text_table where ts >= 0 group by a order by a desc limit 10;
154
154
a | count
155
155
-----------------+-------
156
156
$ | 1000
@@ -166,19 +166,20 @@ select a, count(*) from text_table group by a order by a desc limit 10;
166
166
(10 rows)
167
167
168
168
reset timescaledb.debug_require_vector_agg;
169
+ reset enable_sort;
169
170
-- with NULLS FIRST
170
171
select count(decompress_chunk(x)) from show_chunks('text_table') x;
171
172
count
172
173
-------
173
- 2
174
+ 3
174
175
(1 row)
175
176
176
177
alter table text_table set (timescaledb.compress,
177
178
timescaledb.compress_segmentby = '', timescaledb.compress_orderby = 'a nulls first');
178
179
select count(compress_chunk(x)) from show_chunks('text_table') x;
179
180
count
180
181
-------
181
- 2
182
+ 3
182
183
(1 row)
183
184
184
185
set timescaledb.debug_require_vector_agg to 'require';
@@ -187,14 +188,14 @@ select a, count(*) from text_table group by a order by a nulls first limit 10;
187
188
-------------------------+-------
188
189
$ | 1000
189
190
| 1000
190
- default | 1000
191
191
different-with-nulls1 | 1
192
192
different-with-nulls101 | 1
193
193
different-with-nulls103 | 1
194
194
different-with-nulls105 | 1
195
195
different-with-nulls107 | 1
196
196
different-with-nulls109 | 1
197
197
different-with-nulls11 | 1
198
+ different-with-nulls111 | 1
198
199
(10 rows)
199
200
200
201
reset timescaledb.debug_require_vector_agg;
@@ -203,7 +204,7 @@ set timescaledb.debug_require_vector_agg to 'forbid';
203
204
select ts, a, count(*) from text_table group by ts, a order by ts, a limit 10;
204
205
ts | a | count
205
206
----+---------------+-------
206
- 0 | default | 1000
207
+ -1 | scalar | 1000
207
208
1 | | 1000
208
209
2 | same | 1000
209
210
3 | different1 | 1
@@ -220,14 +221,14 @@ select a, ts, count(*) from text_table group by a, ts order by a desc, ts desc l
220
221
-----------------+----+-------
221
222
$ | 5 | 500
222
223
$ | 4 | 500
224
+ scalar | -1 | 1000
223
225
same-with-nulls | 4 | 500
224
226
same | 2 | 1000
225
227
different999 | 3 | 1
226
228
different998 | 3 | 1
227
229
different997 | 3 | 1
228
230
different996 | 3 | 1
229
231
different995 | 3 | 1
230
- different994 | 3 | 1
231
232
(10 rows)
232
233
233
234
reset timescaledb.debug_require_vector_agg;
0 commit comments