-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
edge
259 lines (225 loc) · 4.89 KB
/
edge
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# LogicTest: local-vec-off fakedist-vec-off
# TODO(yuzefovich): run with all default configs once #40354 is resolved.
# Test on-disk SQL semantics of edge cases and overflows. On-disk is
# important because it avoids any constant folding that could happen
# in the parse or normalization phases, forcing it to be handled by the
# execution engine itself.
# TODO(mjibson): Remove family definition when #41277 is fixed.
statement ok
CREATE TABLE t (
key
STRING PRIMARY KEY,
_date
DATE,
_float4
FLOAT4,
_float8
FLOAT8,
_int2
INT2,
_int4
INT4,
_int8
INT8,
FAMILY "primary" (key, _date, _float4, _float8, _int2, _int4, _int8)
)
statement ok
INSERT
INTO
t
VALUES
(
'min',
'4714-11-24 BC',
-3.40282346638528859811704183484516925440e+38,
-1.7976931348623e+308,
-32768,
-2147483648,
-9223372036854775808
),
(
'max',
'5874897-12-31',
3.40282346638528859811704183484516925440e+38,
1.7976931348623e+308,
32767,
2147483647,
9223372036854775807
)
statement ok
INSERT
INTO
t (key, _date)
VALUES
('+inf', 'infinity'), ('-inf', '-infinity')
# min and min + 1
query TT
SELECT _date, _date + 1 FROM t WHERE key = 'min'
----
-4713-11-24 00:00:00 +0000 +0000 -4713-11-25 00:00:00 +0000 +0000
query IIIIIIRRRR
SELECT
_int2,
_int2 + 1:::INT2,
_int4,
_int4 + 1:::INT4,
_int8,
_int8 + 1:::INT8,
_float4,
_float4 + 1,
_float8,
_float8 + 1
FROM
t
WHERE
key = 'min'
----
-32768 -32767 -2147483648 -2147483647 -9223372036854775808 -9223372036854775807 -3.40282346638529e+38 -3.40282346638529e+38 -1.7976931348623e+308 -1.7976931348623e+308
# min - 1
statement error date is out of range
SELECT _date - 1 FROM t WHERE key = 'min'
# For now we incorrectly do type promotion int2 -> int.
query I
SELECT _int2 - 1:::INT2 FROM t WHERE key = 'min'
----
-32769
# Incorrect type promotion.
query I
SELECT _int4 - 1:::INT4 FROM t WHERE key = 'min'
----
-2147483649
statement error integer out of range
SELECT _int8 - 1:::INT8 FROM t WHERE key = 'min'
query R
SELECT _float8 - 1e300 FROM t WHERE key = 'min'
----
-Inf
# max and max - 1
query TT
SELECT _date, _date - 1 FROM t WHERE key = 'max'
----
5874897-12-31 00:00:00 +0000 +0000 5874897-12-30 00:00:00 +0000 +0000
query IIIIIIRRRR
SELECT
_int2,
_int2 - 1:::INT2,
_int4,
_int4 - 1:::INT4,
_int8,
_int8 - 1:::INT8,
_float4,
_float4 - 1,
_float8,
_float8 - 1
FROM
t
WHERE
key = 'max'
----
32767 32766 2147483647 2147483646 9223372036854775807 9223372036854775806 3.40282346638529e+38 3.40282346638529e+38 1.7976931348623e+308 1.7976931348623e+308
# max + 1
statement error date is out of range
SELECT _date + 1 FROM t WHERE key = 'max'
# For now we incorrectly do type promotion int2 -> int.
query I
SELECT _int2 + 1:::INT2 FROM t WHERE key = 'max'
----
32768
# Incorrect type promotion.
query I
SELECT _int4 + 1:::INT4 FROM t WHERE key = 'max'
----
2147483648
statement error integer out of range
SELECT _int8 + 1:::INT8 FROM t WHERE key = 'max'
query R
SELECT _float8 + 1e300 FROM t WHERE key = 'max'
----
+Inf
# infinity
query TTT
SELECT _date, _date + 1, _date - 1 FROM t WHERE key = '+inf'
----
infinity infinity infinity
query TTT
SELECT _date, _date + 1, _date - 1 FROM t WHERE key = '-inf'
----
-infinity -infinity -infinity
# aggregates
query RRRRRR
SELECT
sum(t._int2),
sum(t._int4),
sum(t._int8),
avg(t._int2),
avg(t._int4),
avg(t._int8)
FROM
t, t AS u
WHERE
t.key = 'max'
----
131068 8589934588 36893488147419103228 32767 2147483647 9223372036854775807
query II
SELECT
sum_int(t._int2), sum_int(t._int4)
FROM
t, t AS u
WHERE
t.key = 'max'
----
131068 8589934588
statement error integer out of range
SELECT sum_int(t._int8) FROM t, t AS u WHERE t.key = 'max'
query RRRRRRRRRR
SELECT
sum(t._int2),
sum(t._int4),
sum(t._int8),
sum(t._float4),
sum(t._float8),
avg(t._int2),
avg(t._int4),
avg(t._int8),
avg(t._float4),
avg(t._float8)
FROM
t, t AS u
WHERE
t.key = 'min'
----
-131072 -8589934592 -36893488147419103232 -1.36112938655412e+39 -Inf -32768 -2147483648 -9223372036854775808 -3.40282346638529e+38 -Inf
query II
SELECT
sum_int(t._int2), sum_int(t._int4)
FROM
t, t AS u
WHERE
t.key = 'min'
----
-131072 -8589934592
statement error integer out of range
SELECT sum_int(t._int8) FROM t, t AS u WHERE t.key = 'min'
query RRRRRRRRRR
SELECT
sum(t._int2),
sum(t._int4),
sum(t._int8),
sum(t._float4),
sum(t._float8),
avg(t._int2),
avg(t._int4),
avg(t._int8),
avg(t._float4),
avg(t._float8)
FROM
t
----
-1 -1 -1 0 0 -0.5 -0.5 -0.5 0 0
query III
SELECT
sum_int(t._int2), sum_int(t._int4), sum_int(t._int8)
FROM
t
----
-1 -1 -1