-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathtopk.slt
232 lines (206 loc) · 7.36 KB
/
topk.slt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Tests for development
statement ok
create table topk(x int) as values (10), (2), (3), (0), (5), (4), (3), (2), (1), (3), (8);
query I
select * from topk order by x;
----
0
1
2
2
3
3
3
4
5
8
10
query I
select * from topk order by x limit 3;
----
0
1
2
query I
select * from topk order by x desc limit 3;
----
10
8
5
statement ok
CREATE EXTERNAL TABLE aggregate_test_100 (
c1 VARCHAR NOT NULL,
c2 TINYINT NOT NULL,
c3 SMALLINT NOT NULL,
c4 SMALLINT,
c5 INT,
c6 BIGINT NOT NULL,
c7 SMALLINT NOT NULL,
c8 INT NOT NULL,
c9 BIGINT UNSIGNED NOT NULL,
c10 VARCHAR NOT NULL,
c11 FLOAT NOT NULL,
c12 DOUBLE NOT NULL,
c13 VARCHAR NOT NULL
)
STORED AS CSV
WITH HEADER ROW
LOCATION '../../testing/data/csv/aggregate_test_100.csv'
query TT
explain select * from aggregate_test_100 ORDER BY c13 desc limit 5;
----
logical_plan
Limit: skip=0, fetch=5
--Sort: aggregate_test_100.c13 DESC NULLS FIRST, fetch=5
----TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13]
physical_plan
GlobalLimitExec: skip=0, fetch=5
--SortExec: fetch=5, expr=[c13@12 DESC]
----CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], has_header=true
query T
select c13 from aggregate_test_100 ORDER BY c13;
----
0VVIHzxWtNOFLtnhjHEKjXaJOSLJfm
0keZ5G8BffGwgF2RwQD59TFzMStxCB
0og6hSkhbX8AC1ktFS4kounvTzy8Vo
1aOcrEGd0cOqZe2I5XBOm0nDcwtBZO
2T3wSlHdEmASmO0xcXHnndkKEt6bz8
3BEOHQsMEFZ58VcNTOJYShTBpAPzbt
4HX6feIvmNXBN7XGqgO4YVBkhu8GDI
4JznSdBajNWhu4hRQwjV1FjTTxY68i
52mKlRE3aHCBZtjECq6sY9OqVf8Dze
56MZa5O1hVtX4c5sbnCfxuX5kDChqI
6FPJlLAcaQ5uokyOWZ9HGdLZObFvOZ
6WfVFBVGJSQb7FhA7E0lBwdvjfZnSW
6oIXZuIPIqEoPBvFmbt2Nxy3tryGUE
6x93sxYioWuq5c9Kkk8oTAAORM7cH0
802bgTGl6Bk5TlkPYYTxp5JkKyaYUA
8LIh0b6jmDGm87BmIyjdxNIpX4ugjD
90g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RF5hYSsmksS
nYVJnVicpGRqKZibHyBAmtmzBXAFfT
oHJMNvWuunsIMIWFnYG31RCfkOo2V7
oLZ21P2JEDooxV1pU31cIxQHEeeoLu
okOkcWflkNXIy4R8LzmySyY1EC3sYd
pLk3i59bZwd5KBZrI1FiweYTd5hteG
pTeu0WMjBRTaNRT15rLCuEh3tBJVc5
qnPOOmslCJaT45buUisMRnM0rc77EK
t6fQUjJejPcjc04wHvHTPe55S65B4V
ukOiFGGFnQJDHFgZxHMpvhD3zybF0M
ukyD7b0Efj7tNlFSRmzZ0IqkEzg2a8
waIGbOGl1PM6gnzZ4uuZt4E2yDWRHs
wwXqSGKLyBQyPkonlzBNYUJTCo4LRS
xipQ93429ksjNcXPX5326VSg1xJZcW
y7C453hRWd4E7ImjNDWlpexB8nUqjh
ydkwycaISlYSlEq3TlkS2m15I2pcp8
query TIIIIIIIITRRT
select * from aggregate_test_100 ORDER BY c13 desc limit 5;
----
a 4 -38 20744 762932956 308913475857409919 7 45465 1787652631 878137512938218976 0.7459874 0.021825780392 ydkwycaISlYSlEq3TlkS2m15I2pcp8
d 1 -98 13630 -1991133944 1184110014998006843 220 2986 225513085 9634106610243643486 0.89651865 0.164088254508 y7C453hRWd4E7ImjNDWlpexB8nUqjh
e 2 52 -12056 -1090239422 9011500141803970147 238 4168 2013662838 12565360638488684051 0.6694766 0.391444365692 xipQ93429ksjNcXPX5326VSg1xJZcW
d 1 -72 25590 1188089983 3090286296481837049 241 832 3542840110 5885937420286765261 0.41980565 0.215354023438 wwXqSGKLyBQyPkonlzBNYUJTCo4LRS
a 1 -5 12636 794623392 2909750622865366631 15 24022 2669374863 4776679784701509574 0.29877836 0.253725340799 waIGbOGl1PM6gnzZ4uuZt4E2yDWRHs
## -- make tiny batches to trigger batch compaction
statement ok
set datafusion.execution.batch_size = 2
query TIIIIIIIITRRT
select * from aggregate_test_100 ORDER BY c13 desc limit 5;
----
a 4 -38 20744 762932956 308913475857409919 7 45465 1787652631 878137512938218976 0.7459874 0.021825780392 ydkwycaISlYSlEq3TlkS2m15I2pcp8
d 1 -98 13630 -1991133944 1184110014998006843 220 2986 225513085 9634106610243643486 0.89651865 0.164088254508 y7C453hRWd4E7ImjNDWlpexB8nUqjh
e 2 52 -12056 -1090239422 9011500141803970147 238 4168 2013662838 12565360638488684051 0.6694766 0.391444365692 xipQ93429ksjNcXPX5326VSg1xJZcW
d 1 -72 25590 1188089983 3090286296481837049 241 832 3542840110 5885937420286765261 0.41980565 0.215354023438 wwXqSGKLyBQyPkonlzBNYUJTCo4LRS
a 1 -5 12636 794623392 2909750622865366631 15 24022 2669374863 4776679784701509574 0.29877836 0.253725340799 waIGbOGl1PM6gnzZ4uuZt4E2yDWRHs
## make an example for dictionary encoding
statement ok
create table dict as select c1, c2, c3, c13, arrow_cast(c13, 'Dictionary(Int32, Utf8)') as c13_dict from aggregate_test_100;
query TIIT?
select * from dict order by c13 desc limit 5;
----
a 4 -38 ydkwycaISlYSlEq3TlkS2m15I2pcp8 ydkwycaISlYSlEq3TlkS2m15I2pcp8
d 1 -98 y7C453hRWd4E7ImjNDWlpexB8nUqjh y7C453hRWd4E7ImjNDWlpexB8nUqjh
e 2 52 xipQ93429ksjNcXPX5326VSg1xJZcW xipQ93429ksjNcXPX5326VSg1xJZcW
d 1 -72 wwXqSGKLyBQyPkonlzBNYUJTCo4LRS wwXqSGKLyBQyPkonlzBNYUJTCo4LRS
a 1 -5 waIGbOGl1PM6gnzZ4uuZt4E2yDWRHs waIGbOGl1PM6gnzZ4uuZt4E2yDWRHs