123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- # 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/database-issues/issues/5797,
- # 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/database-issues/issues/436).
- 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
|