ClickHouse/tests/queries/0_stateless/02685_decimal256_various.reference
2023-03-15 02:35:41 +01:00

98 lines
4.7 KiB
Plaintext

-- { echoOn }
SELECT 1.1::Decimal(60, 30);
1.1
SELECT round(1.1::Decimal(60, 30));
1
SELECT round(1.1::Decimal(60, 30), 1);
1.1
SELECT round(1.234567890123456789012345678901::Decimal(60, 30), 1);
1.2
SELECT round(1.234567890123456789012345678901::Decimal(60, 30), 30);
1.234567890123456789012345678901
SELECT round(1.234567890123456789012345678901::Decimal(60, 30), 31);
1.234567890123456789012345678901
SELECT round(1.234567890123456789012345678901::Decimal(60, 30), 20);
1.23456789012345678901
SELECT hex(1.234567890123456789012345678901::Decimal(60, 30));
356C760E4FC986A2A39F1A950F00000000000000000000000000000000000000
SELECT bin(1.234567890123456789012345678901::Decimal(60, 30));
0011010101101100011101100000111001001111110010011000011010100010101000111001111100011010100101010000111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
SELECT reinterpret(unhex(hex(1.234567890123456789012345678901::Decimal(60, 30))), 'Decimal(60, 30)');
1.234567890123456789012345678901
SELECT arraySum([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
4.65
SELECT arraySum([1.2::Decimal(60, 30), 3.45::Decimal(3, 2)]);
4.65
SELECT arrayMin([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
1.2
SELECT arrayMax([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
3.45
SELECT arrayAvg([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
2.325
SELECT round(arrayProduct([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]), 6);
4.14
SELECT toTypeName(arrayProduct([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]));
Float64
SELECT arrayCumSum([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
[1.2,4.65]
SELECT arrayCumSumNonNegative([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
[1.2,4.65]
SELECT arrayDifference([1.2::Decimal(60, 30), 3.45::Decimal(61, 29)]);
[0,2.25]
SELECT arrayCompact([1.2::Decimal(60, 30) AS x, x, x, x, 3.45::Decimal(3, 2) AS y, y, x, x]);
[1.2,3.45,1.2]
SELECT 1.2::Decimal(2, 1) IN (1.2::Decimal(60, 30), 3.4::Decimal(60, 30));
1
SELECT 1.23::Decimal(3, 2) IN (1.2::Decimal(60, 30), 3.4::Decimal(60, 30));
0
SELECT 1.2::Decimal(60, 30) IN (1.2::Decimal(2, 1));
1
SELECT toTypeName([1.2::Decimal(60, 30), 3.45::Decimal(3, 2)]);
Array(Decimal(76, 30))
SELECT toTypeName(arraySum([1.2::Decimal(60, 30), 3.45::Decimal(3, 2)]));
Decimal(76, 30)
SELECT arrayJoin(sumMap(x)) FROM (SELECT [('Hello', 1.2::Decimal256(30)), ('World', 3.4::Decimal256(30))]::Map(String, Decimal256(30)) AS x UNION ALL SELECT [('World', 5.6::Decimal256(30)), ('GoodBye', -111.222::Decimal256(30))]::Map(String, Decimal256(30))) ORDER BY 1;
('GoodBye',-111.222)
('Hello',1.2)
('World',9)
SELECT mapAdd(map('Hello', 1.2::Decimal128(30), 'World', 3.4::Decimal128(30)), map('World', 5.6::Decimal128(30), 'GoodBye', -111.222::Decimal128(30)));
{'GoodBye':-111.222,'Hello':1.2,'World':9}
SELECT mapSubtract(map('Hello', 1.2::Decimal128(30), 'World', 3.4::Decimal128(30)), map('World', 5.6::Decimal128(30), 'GoodBye', -111.222::Decimal128(30)));
{'GoodBye':111.222,'Hello':1.2,'World':-2.2}
SELECT arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(UInt256)));
[2,3]
SELECT toTypeName(arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(UInt128))));
Array(UInt128)
SELECT toTypeName(arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(Int128))));
Array(Int128)
SELECT arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(Int128)));
[2,3]
SELECT arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(Int8)));
[2,3]
SELECT toTypeName(arraySort(arrayIntersect([1, 2, 3]::Array(UInt256), [2, 3, 4]::Array(Int8))));
Array(Int8)
SELECT arraySort(arrayIntersect([1.1::Decimal256(70), 2.34::Decimal256(60), 3.456::Decimal256(50)], [2.34::Decimal256(65), 3.456::Decimal256(55), 4.5678::Decimal256(45)]));
[2.34,3.456]
SELECT arraySort(arrayIntersect([1.1::Decimal256(1)], [1.12::Decimal256(2)])); -- Note: this is correct but the semantics has to be clarified in the docs.
[1.1]
SELECT arraySort(arrayIntersect([1.1::Decimal256(2)], [1.12::Decimal256(2)]));
[]
SELECT arraySort(arrayIntersect([1.1::Decimal128(1)], [1.12::Decimal128(2)])); -- Note: this is correct but the semantics has to be clarified in the docs.
[1.1]
SELECT arraySort(arrayIntersect([1.1::Decimal128(2)], [1.12::Decimal128(2)]));
[]
select coalesce(cast('123', 'Nullable(Decimal(20, 10))'), 0);
123
select coalesce(cast('123', 'Nullable(Decimal(40, 10))'), 0);
123
select coalesce(cast('123', 'Decimal(40, 10)'), 0);
123
DROP TABLE IF EXISTS decimal_insert_cast_issue;
create table decimal_insert_cast_issue (a Decimal(76, 0)) engine = TinyLog;
SET param_param = 1;
INSERT INTO decimal_insert_cast_issue VALUES ({param:Nullable(Decimal(41, 0))});
SELECT * FROM decimal_insert_cast_issue;
1
DROP TABLE decimal_insert_cast_issue;