forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-19511.slt
111 lines (91 loc) · 2.85 KB
/
github-19511.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
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
mode cockroach
# The following is a regression test for cases 3), 4), and 6)
# of https://github.com/MaterializeInc/materialize/issues/19511,
# where aggregate functions would type-promote to floating point,
# but could promote to numeric.
statement ok
CREATE TABLE t_19511_case_3 (row_index INT, decimal_39_8_val DECIMAL(39,8));
statement ok
INSERT INTO t_19511_case_3 VALUES (3, 9999999999999999999999999999999.99999999::DECIMAL(39,8));
statement ok
INSERT INTO t_19511_case_3 VALUES (4, -9999999999999999999999999999999.99999999::DECIMAL(39,8));
statement ok
CREATE OR REPLACE VIEW v_19511_case_3 (row_index, decimal_39_8_val)
AS SELECT 3, 9999999999999999999999999999999.99999999::DECIMAL(39,8)
UNION SELECT 4, -9999999999999999999999999999999.99999999::DECIMAL(39,8);
# Note that we get an error in the evaluation of this case, while
# PostgreSQL successfully computes a result. This is due to the
# precision of our numeric types vs. the algorithm used to calculate
# standard deviation (https://github.com/MaterializeInc/materialize/issues/1240).
query error
SELECT
stddev_samp(decimal_39_8_val)
FROM
t_19511_case_3
WHERE row_index IN (3, 4);
query error
SELECT
stddev_samp(decimal_39_8_val)
FROM
WHERE row_index IN (3, 4);
v_19511_case_3
statement ok
CREATE TABLE t_19511_case_4 (row_index INT, int8_val INT8);
statement ok
INSERT INTO t_19511_case_4 VALUES (5, 0::INT8);
statement ok
INSERT INTO t_19511_case_4 VALUES (7, 9223372036854775807::INT8);
statement ok
CREATE OR REPLACE VIEW v_19511_case_4 (row_index, int8_val)
AS SELECT 5, 0::INT8
UNION SELECT 7, 9223372036854775807::INT8;
query R
SELECT
stddev_pop(int8_val)
FROM
t_19511_case_4
WHERE row_index IN (5, 7);
----
4611686018427387903.50000000000000000001
query R
SELECT
stddev_pop(int8_val)
FROM
v_19511_case_4
WHERE row_index IN (5, 7);
----
4611686018427387903.50000000000000000001
statement ok
CREATE TABLE t_19511_case_6 (row_index INT, decimal_39_8_val DECIMAL(39,8));
statement ok
INSERT INTO t_19511_case_6 VALUES (6, 1.00000001::DECIMAL(39,8));
statement ok
INSERT INTO t_19511_case_6 VALUES (8, 0.99999999::DECIMAL(39,8));
statement ok
CREATE OR REPLACE VIEW v_19511_case_6 (row_index, decimal_39_8_val)
AS SELECT 6, 1.00000001::DECIMAL(39,8)
UNION SELECT 8, 0.99999999::DECIMAL(39,8);
query R
SELECT
stddev_pop(decimal_39_8_val)
FROM
t_19511_case_6
WHERE row_index IN (8, 6);
----
0.00000001
query R
SELECT
stddev_pop(decimal_39_8_val)
FROM
v_19511_case_6
WHERE row_index IN (8, 6);
----
0.00000001