test for decimal + column defaults [CLICKHOUSE-3765]

This commit is contained in:
chertus 2018-09-18 15:08:54 +03:00
parent 599ec4c577
commit fee5f24326
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,14 @@
a Decimal(9, 4) DEFAULT CAST(0, \'Decimal(9, 4)\')
b Decimal(18, 4) DEFAULT CAST(a / 2, \'Decimal(18, 4)\')
c Decimal(38, 4) DEFAULT CAST(b / 3, \'Decimal(38, 4)\')
d Decimal(9, 4) MATERIALIZED a + toDecimal32(\'0.2\', 1)
e Decimal(18, 4) ALIAS b * 2
f Decimal(38, 4) ALIAS c * 6
0.0000 0.0000 0.0000
1.0000 0.5000 0.1666
2.0000 1.0000 0.3333
3.0000 1.5000 0.5000
0.0000 0.0000 0.0000 0.2000 0.0000 0.0000
1.0000 0.5000 0.1666 1.2000 1.0000 0.9996
2.0000 1.0000 0.3333 2.2000 2.0000 1.9998
3.0000 1.5000 0.5000 3.2000 3.0000 3.0000

View File

@ -0,0 +1,23 @@
SET allow_experimental_decimal_type = 1;
SET send_logs_level = 'none';
CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.decimal;
CREATE TABLE IF NOT EXISTS test.decimal
(
a DECIMAL(9,4) DEFAULT 0,
b DECIMAL(18,4) DEFAULT a / 2,
c DECIMAL(38,4) DEFAULT b / 3,
d MATERIALIZED a + toDecimal32('0.2', 1),
e ALIAS b * 2,
f ALIAS c * 6
) ENGINE = Memory;
DESC TABLE test.decimal;
INSERT INTO test.decimal (a) VALUES (0), (1), (2), (3);
SELECT * FROM test.decimal;
SELECT a, b, c, d, e, f FROM test.decimal;
DROP TABLE IF EXISTS test.decimal;