added proper test for avg()

This commit is contained in:
myrrc 2020-11-05 11:12:04 +03:00
parent 9788065786
commit c09fcf846d
2 changed files with 46 additions and 9 deletions

View File

@ -1,2 +1,5 @@
nan
499.5
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
-0.5 -0.5 -0.5 -0.5 -0.5 -0.5 127.493856 32355.57552 499999.5 499999.5 499999.5 499999.5 499999.5 -0.000500002 0.49999949943727 -0.000005 1.7009999999999985e-8
-2767.546272
999999
-0.50000449943727

View File

@ -1,9 +1,43 @@
CREATE TABLE IF NOT EXISTS test_01035 (
t UInt16
) ENGINE = Memory;
SET allow_experimental_bigint_types=1;
SELECT avg(t) FROM test_01035;
INSERT INTO test_01035 SELECT * FROM system.numbers LIMIT 1000;
SELECT avg(t) FROM test_01035;
-- no UInt128 as for now
CREATE TABLE IF NOT EXISTS test_01035_avg (
i8 Int8 DEFAULT i64,
i16 Int16 DEFAULT i64,
i32 Int32 DEFAULT i64,
i64 Int64 DEFAULT if(u64 % 2 = 0, toInt64(u64), toInt64(-u64)),
i128 Int128 DEFAULT i64,
i256 Int256 DEFAULT i64,
DROP TABLE IF EXISTS test_01035
u8 UInt8 DEFAULT u64,
u16 UInt16 DEFAULT u64,
u32 UInt32 DEFAULT u64,
u64 UInt64,
u256 UInt256 DEFAULT u64,
f32 Float32 DEFAULT u64,
f64 Float64 DEFAULT u64,
d32 Decimal32(4) DEFAULT toDecimal32(i32 / 1000, 4),
d64 Decimal64(18) DEFAULT toDecimal64(u64 / 1000000, 8),
d128 Decimal128(20) DEFAULT toDecimal128(i128 / 100000, 20),
d256 Decimal256(40) DEFAULT toDecimal256(i256 / 100000, 40)
) ENGINE = MergeTree() ORDER BY i64;
SELECT avg(i8), avg(i16), avg(i32), avg(i64), avg(i128), avg(i256),
avg(u8), avg(u16), avg(u32), avg(u64), avg(u256),
avg(f32), avg(f64),
avg(d32), avg(d64), avg(d128), avg(d256) FROM test_01035_avg;
INSERT INTO test_01035_avg (u64) SELECT number FROM system.numbers LIMIT 1000000;
SELECT avg(i8), avg(i16), avg(i32), avg(i64), avg(i128), avg(i256),
avg(u8), avg(u16), avg(u32), avg(u64), avg(u256),
avg(f32), avg(f64),
avg(d32), avg(d64), avg(d128), avg(d256) FROM test_01035_avg;
SELECT avg(i8 * i16) FROM test_01035_avg;
SELECT avg(f32 + f64) FROM test_01035_avg;
SELECT avg(d128 - d64) FROM test_01035_avg;
DROP TABLE IF EXISTS test_01035_avg;