diff --git a/tests/queries/0_stateless/00700_decimal_casts.reference b/tests/queries/0_stateless/00700_decimal_casts.reference index e975ae0aee8..99d8b949398 100644 --- a/tests/queries/0_stateless/00700_decimal_casts.reference +++ b/tests/queries/0_stateless/00700_decimal_casts.reference @@ -157,40 +157,3 @@ 0.12345678 0.12345678912345678 0.1234567890123456789012345678901234567 -1234567890.0000000000000000000000000000 1234567890.00000000000000000000000000000 1234567890.00000000000000000000000000000 --126561577.683753853853498429727072845824 -1234567890.00000000 1234567890.000000000 1234567890.000000000 -12345678.0 12345678.00 12345678.00 -9223372036854775807.000000 9223372036854775807 -9223372036854775807 -9223372036854775800 9223372036854775800 -9223372036854775800 -92233720368547758.00 92233720368547758 -92233720368547758 -2147483647.0000000000 2147483647 -2147483647 -2147483647.00 2147483647 -2147483647 -92233720368547757.99 92233720368547757 -92233720368547757 -2147483640.99 2147483640 -2147483640 --0.90000000 0 --0.90000000 0 --0.90000000 0 --0.8000 0 --0.8000 0 --0.8000 0 --0.70 0 --0.70 0 --0.70 0 --0.600000 0 --0.600000 0 --0.600000 0 -18446744073709551615 18446744073709551615 -18446744073709551615.00000000 18446744073709551615 -4294967295 4294967295 -4294967295.0000000000 4294967295 -4294967295 4294967295 -4294967295.0000 4294967295 -65535 65535 -65535.0000000000 65535 -65535 65535 -65535.0000 65535 -2147483647 2147483647 --2147483647 -2147483647 -2147483647 2147483647 -9223372036854775807 9223372036854775807 diff --git a/tests/queries/0_stateless/00700_decimal_casts.sql b/tests/queries/0_stateless/00700_decimal_casts.sql index e7f9736283c..8c752565fee 100644 --- a/tests/queries/0_stateless/00700_decimal_casts.sql +++ b/tests/queries/0_stateless/00700_decimal_casts.sql @@ -146,123 +146,3 @@ SELECT CAST('0.12345678901234567890123456789012345678', 'Decimal(38,38)'); SELECT CAST('0.123456789', 'Decimal(9,8)'); SELECT CAST('0.123456789123456789', 'Decimal(18,17)'); SELECT CAST('0.12345678901234567890123456789012345678', 'Decimal(38,37)'); - -SELECT toDecimal128('1234567890', 28) AS x, toDecimal128(x, 29), toDecimal128(toDecimal128('1234567890', 28), 29); -SELECT toDecimal128(toDecimal128('1234567890', 28), 30); - -SELECT toDecimal64('1234567890', 8) AS x, toDecimal64(x, 9), toDecimal64(toDecimal64('1234567890', 8), 9); -SELECT toDecimal64(toDecimal64('1234567890', 8), 10); -- { serverError 407 } - -SELECT toDecimal32('12345678', 1) AS x, toDecimal32(x, 2), toDecimal32(toDecimal32('12345678', 1), 2); -SELECT toDecimal32(toDecimal32('12345678', 1), 3); -- { serverError 407 } - -SELECT toDecimal64(toDecimal64('92233720368547758.1', 1), 2); -- { serverError 407 } -SELECT toDecimal64(toDecimal64('-92233720368547758.1', 1), 2); -- { serverError 407 } - -SELECT toDecimal128('9223372036854775807', 6) AS x, toInt64(x), toInt64(-x); -SELECT toDecimal128('9223372036854775809', 6) AS x, toInt64(x); -- { serverError 407 } -SELECT toDecimal128('9223372036854775809', 6) AS x, toInt64(-x); -- { serverError 407 } -SELECT toDecimal64('922337203685477580', 0) * 10 AS x, toInt64(x), toInt64(-x); -SELECT toDecimal64(toDecimal64('92233720368547758.0', 1), 2) AS x, toInt64(x), toInt64(-x); - -SELECT toDecimal128('2147483647', 10) AS x, toInt32(x), toInt32(-x); -SELECT toDecimal128('2147483649', 10) AS x, toInt32(x), toInt32(-x); -- { serverError 407 } -SELECT toDecimal64('2147483647', 2) AS x, toInt32(x), toInt32(-x); -SELECT toDecimal64('2147483649', 2) AS x, toInt32(x), toInt32(-x); -- { serverError 407 } - -SELECT toDecimal128('92233720368547757.99', 2) AS x, toInt64(x), toInt64(-x); -SELECT toDecimal64('2147483640.99', 2) AS x, toInt32(x), toInt32(-x); - -SELECT toDecimal128('-0.9', 8) AS x, toUInt64(x); -SELECT toDecimal64('-0.9', 8) AS x, toUInt64(x); -SELECT toDecimal32('-0.9', 8) AS x, toUInt64(x); - -SELECT toDecimal128('-0.8', 4) AS x, toUInt32(x); -SELECT toDecimal64('-0.8', 4) AS x, toUInt32(x); -SELECT toDecimal32('-0.8', 4) AS x, toUInt32(x); - -SELECT toDecimal128('-0.7', 2) AS x, toUInt16(x); -SELECT toDecimal64('-0.7', 2) AS x, toUInt16(x); -SELECT toDecimal32('-0.7', 2) AS x, toUInt16(x); - -SELECT toDecimal128('-0.6', 6) AS x, toUInt8(x); -SELECT toDecimal64('-0.6', 6) AS x, toUInt8(x); -SELECT toDecimal32('-0.6', 6) AS x, toUInt8(x); - -SELECT toDecimal128('-1', 7) AS x, toUInt64(x); -- { serverError 407 } -SELECT toDecimal128('-1', 7) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal128('-1', 7) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal128('-1', 7) AS x, toUInt8(x); -- { serverError 407 } - -SELECT toDecimal64('-1', 5) AS x, toUInt64(x); -- { serverError 407 } -SELECT toDecimal64('-1', 5) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal64('-1', 5) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal64('-1', 5) AS x, toUInt8(x); -- { serverError 407 } - -SELECT toDecimal32('-1', 3) AS x, toUInt64(x); -- { serverError 407 } -SELECT toDecimal32('-1', 3) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal32('-1', 3) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal32('-1', 3) AS x, toUInt8(x); -- { serverError 407 } - -SELECT toDecimal128('18446744073709551615', 0) AS x, toUInt64(x); -SELECT toDecimal128('18446744073709551616', 0) AS x, toUInt64(x); -- { serverError 407 } -SELECT toDecimal128('18446744073709551615', 8) AS x, toUInt64(x); -SELECT toDecimal128('18446744073709551616', 8) AS x, toUInt64(x); -- { serverError 407 } - -SELECT toDecimal128('4294967295', 0) AS x, toUInt32(x); -SELECT toDecimal128('4294967296', 0) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal128('4294967295', 10) AS x, toUInt32(x); -SELECT toDecimal128('4294967296', 10) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal64('4294967295', 0) AS x, toUInt32(x); -SELECT toDecimal64('4294967296', 0) AS x, toUInt32(x); -- { serverError 407 } -SELECT toDecimal64('4294967295', 4) AS x, toUInt32(x); -SELECT toDecimal64('4294967296', 4) AS x, toUInt32(x); -- { serverError 407 } - -SELECT toDecimal128('65535', 0) AS x, toUInt16(x); -SELECT toDecimal128('65536', 0) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal128('65535', 10) AS x, toUInt16(x); -SELECT toDecimal128('65536', 10) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal64('65535', 0) AS x, toUInt16(x); -SELECT toDecimal64('65536', 0) AS x, toUInt16(x); -- { serverError 407 } -SELECT toDecimal64('65535', 4) AS x, toUInt16(x); -SELECT toDecimal64('65536', 4) AS x, toUInt16(x); -- { serverError 407 } - -SELECT toInt64('2147483647') AS x, toDecimal32(x, 0); -SELECT toInt64('-2147483647') AS x, toDecimal32(x, 0); -SELECT toUInt64('2147483647') AS x, toDecimal32(x, 0); -SELECT toInt64('2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } -SELECT toInt64('-2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } -SELECT toUInt64('2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } - -SELECT toUInt64('9223372036854775807') AS x, toDecimal64(x, 0); -SELECT toUInt64('9223372036854775809') AS x, toDecimal64(x, 0); -- { serverError 407 } - -SELECT toDecimal32(0, rowNumberInBlock()); -- { serverError 44 } -SELECT toDecimal64(0, rowNumberInBlock()); -- { serverError 44 } -SELECT toDecimal128(0, rowNumberInBlock()); -- { serverError 44 } - -SELECT toDecimal32(1/0, 0); -- { serverError 407 } -SELECT toDecimal64(1/0, 1); -- { serverError 407 } -SELECT toDecimal128(0/0, 2); -- { serverError 407 } -SELECT CAST(1/0, 'Decimal(9, 0)'); -- { serverError 407 } -SELECT CAST(1/0, 'Decimal(18, 1)'); -- { serverError 407 } -SELECT CAST(1/0, 'Decimal(38, 2)'); -- { serverError 407 } -SELECT CAST(0/0, 'Decimal(9, 3)'); -- { serverError 407 } -SELECT CAST(0/0, 'Decimal(18, 4)'); -- { serverError 407 } -SELECT CAST(0/0, 'Decimal(38, 5)'); -- { serverError 407 } - -select toDecimal32(10000.1, 6); -- { serverError 407 } -select toDecimal64(10000.1, 18); -- { serverError 407 } -select toDecimal128(1000000000000000000000.1, 18); -- { serverError 407 } - -select toDecimal32(-10000.1, 6); -- { serverError 407 } -select toDecimal64(-10000.1, 18); -- { serverError 407 } -select toDecimal128(-1000000000000000000000.1, 18); -- { serverError 407 } - -select toDecimal32(2147483647.0 + 1.0, 0); -- { serverError 407 } -select toDecimal64(9223372036854775807.0, 0); -- { serverError 407 } -select toDecimal128(170141183460469231731687303715884105729.0, 0); -- { serverError 407 } - -select toDecimal32(-2147483647.0 - 1.0, 0); -- { serverError 407 } -select toDecimal64(-9223372036854775807.0, 0); -- { serverError 407 } -select toDecimal128(-170141183460469231731687303715884105729.0, 0); -- { serverError 407 } diff --git a/tests/queries/0_stateless/00700_decimal_casts_2.reference b/tests/queries/0_stateless/00700_decimal_casts_2.reference new file mode 100644 index 00000000000..393baae6c47 --- /dev/null +++ b/tests/queries/0_stateless/00700_decimal_casts_2.reference @@ -0,0 +1,37 @@ +1234567890.0000000000000000000000000000 1234567890.00000000000000000000000000000 1234567890.00000000000000000000000000000 +-126561577.683753853853498429727072845824 +1234567890.00000000 1234567890.000000000 1234567890.000000000 +12345678.0 12345678.00 12345678.00 +9223372036854775807.000000 9223372036854775807 -9223372036854775807 +9223372036854775800 9223372036854775800 -9223372036854775800 +92233720368547758.00 92233720368547758 -92233720368547758 +2147483647.0000000000 2147483647 -2147483647 +2147483647.00 2147483647 -2147483647 +92233720368547757.99 92233720368547757 -92233720368547757 +2147483640.99 2147483640 -2147483640 +-0.90000000 0 +-0.90000000 0 +-0.90000000 0 +-0.8000 0 +-0.8000 0 +-0.8000 0 +-0.70 0 +-0.70 0 +-0.70 0 +-0.600000 0 +-0.600000 0 +-0.600000 0 +18446744073709551615 18446744073709551615 +18446744073709551615.00000000 18446744073709551615 +4294967295 4294967295 +4294967295.0000000000 4294967295 +4294967295 4294967295 +4294967295.0000 4294967295 +65535 65535 +65535.0000000000 65535 +65535 65535 +65535.0000 65535 +2147483647 2147483647 +-2147483647 -2147483647 +2147483647 2147483647 +9223372036854775807 9223372036854775807 diff --git a/tests/queries/0_stateless/00700_decimal_casts_2.sql b/tests/queries/0_stateless/00700_decimal_casts_2.sql new file mode 100644 index 00000000000..89c95fed271 --- /dev/null +++ b/tests/queries/0_stateless/00700_decimal_casts_2.sql @@ -0,0 +1,119 @@ +SELECT toDecimal128('1234567890', 28) AS x, toDecimal128(x, 29), toDecimal128(toDecimal128('1234567890', 28), 29); +SELECT toDecimal128(toDecimal128('1234567890', 28), 30); + +SELECT toDecimal64('1234567890', 8) AS x, toDecimal64(x, 9), toDecimal64(toDecimal64('1234567890', 8), 9); +SELECT toDecimal64(toDecimal64('1234567890', 8), 10); -- { serverError 407 } + +SELECT toDecimal32('12345678', 1) AS x, toDecimal32(x, 2), toDecimal32(toDecimal32('12345678', 1), 2); +SELECT toDecimal32(toDecimal32('12345678', 1), 3); -- { serverError 407 } + +SELECT toDecimal64(toDecimal64('92233720368547758.1', 1), 2); -- { serverError 407 } +SELECT toDecimal64(toDecimal64('-92233720368547758.1', 1), 2); -- { serverError 407 } + +SELECT toDecimal128('9223372036854775807', 6) AS x, toInt64(x), toInt64(-x); +SELECT toDecimal128('9223372036854775809', 6) AS x, toInt64(x); -- { serverError 407 } +SELECT toDecimal128('9223372036854775809', 6) AS x, toInt64(-x); -- { serverError 407 } +SELECT toDecimal64('922337203685477580', 0) * 10 AS x, toInt64(x), toInt64(-x); +SELECT toDecimal64(toDecimal64('92233720368547758.0', 1), 2) AS x, toInt64(x), toInt64(-x); + +SELECT toDecimal128('2147483647', 10) AS x, toInt32(x), toInt32(-x); +SELECT toDecimal128('2147483649', 10) AS x, toInt32(x), toInt32(-x); -- { serverError 407 } +SELECT toDecimal64('2147483647', 2) AS x, toInt32(x), toInt32(-x); +SELECT toDecimal64('2147483649', 2) AS x, toInt32(x), toInt32(-x); -- { serverError 407 } + +SELECT toDecimal128('92233720368547757.99', 2) AS x, toInt64(x), toInt64(-x); +SELECT toDecimal64('2147483640.99', 2) AS x, toInt32(x), toInt32(-x); + +SELECT toDecimal128('-0.9', 8) AS x, toUInt64(x); +SELECT toDecimal64('-0.9', 8) AS x, toUInt64(x); +SELECT toDecimal32('-0.9', 8) AS x, toUInt64(x); + +SELECT toDecimal128('-0.8', 4) AS x, toUInt32(x); +SELECT toDecimal64('-0.8', 4) AS x, toUInt32(x); +SELECT toDecimal32('-0.8', 4) AS x, toUInt32(x); + +SELECT toDecimal128('-0.7', 2) AS x, toUInt16(x); +SELECT toDecimal64('-0.7', 2) AS x, toUInt16(x); +SELECT toDecimal32('-0.7', 2) AS x, toUInt16(x); + +SELECT toDecimal128('-0.6', 6) AS x, toUInt8(x); +SELECT toDecimal64('-0.6', 6) AS x, toUInt8(x); +SELECT toDecimal32('-0.6', 6) AS x, toUInt8(x); + +SELECT toDecimal128('-1', 7) AS x, toUInt64(x); -- { serverError 407 } +SELECT toDecimal128('-1', 7) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal128('-1', 7) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal128('-1', 7) AS x, toUInt8(x); -- { serverError 407 } + +SELECT toDecimal64('-1', 5) AS x, toUInt64(x); -- { serverError 407 } +SELECT toDecimal64('-1', 5) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal64('-1', 5) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal64('-1', 5) AS x, toUInt8(x); -- { serverError 407 } + +SELECT toDecimal32('-1', 3) AS x, toUInt64(x); -- { serverError 407 } +SELECT toDecimal32('-1', 3) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal32('-1', 3) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal32('-1', 3) AS x, toUInt8(x); -- { serverError 407 } + +SELECT toDecimal128('18446744073709551615', 0) AS x, toUInt64(x); +SELECT toDecimal128('18446744073709551616', 0) AS x, toUInt64(x); -- { serverError 407 } +SELECT toDecimal128('18446744073709551615', 8) AS x, toUInt64(x); +SELECT toDecimal128('18446744073709551616', 8) AS x, toUInt64(x); -- { serverError 407 } + +SELECT toDecimal128('4294967295', 0) AS x, toUInt32(x); +SELECT toDecimal128('4294967296', 0) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal128('4294967295', 10) AS x, toUInt32(x); +SELECT toDecimal128('4294967296', 10) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal64('4294967295', 0) AS x, toUInt32(x); +SELECT toDecimal64('4294967296', 0) AS x, toUInt32(x); -- { serverError 407 } +SELECT toDecimal64('4294967295', 4) AS x, toUInt32(x); +SELECT toDecimal64('4294967296', 4) AS x, toUInt32(x); -- { serverError 407 } + +SELECT toDecimal128('65535', 0) AS x, toUInt16(x); +SELECT toDecimal128('65536', 0) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal128('65535', 10) AS x, toUInt16(x); +SELECT toDecimal128('65536', 10) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal64('65535', 0) AS x, toUInt16(x); +SELECT toDecimal64('65536', 0) AS x, toUInt16(x); -- { serverError 407 } +SELECT toDecimal64('65535', 4) AS x, toUInt16(x); +SELECT toDecimal64('65536', 4) AS x, toUInt16(x); -- { serverError 407 } + +SELECT toInt64('2147483647') AS x, toDecimal32(x, 0); +SELECT toInt64('-2147483647') AS x, toDecimal32(x, 0); +SELECT toUInt64('2147483647') AS x, toDecimal32(x, 0); +SELECT toInt64('2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } +SELECT toInt64('-2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } +SELECT toUInt64('2147483649') AS x, toDecimal32(x, 0); -- { serverError 407 } + +SELECT toUInt64('9223372036854775807') AS x, toDecimal64(x, 0); +SELECT toUInt64('9223372036854775809') AS x, toDecimal64(x, 0); -- { serverError 407 } + +SELECT toDecimal32(0, rowNumberInBlock()); -- { serverError 44 } +SELECT toDecimal64(0, rowNumberInBlock()); -- { serverError 44 } +SELECT toDecimal128(0, rowNumberInBlock()); -- { serverError 44 } + +SELECT toDecimal32(1/0, 0); -- { serverError 407 } +SELECT toDecimal64(1/0, 1); -- { serverError 407 } +SELECT toDecimal128(0/0, 2); -- { serverError 407 } +SELECT CAST(1/0, 'Decimal(9, 0)'); -- { serverError 407 } +SELECT CAST(1/0, 'Decimal(18, 1)'); -- { serverError 407 } +SELECT CAST(1/0, 'Decimal(38, 2)'); -- { serverError 407 } +SELECT CAST(0/0, 'Decimal(9, 3)'); -- { serverError 407 } +SELECT CAST(0/0, 'Decimal(18, 4)'); -- { serverError 407 } +SELECT CAST(0/0, 'Decimal(38, 5)'); -- { serverError 407 } + +select toDecimal32(10000.1, 6); -- { serverError 407 } +select toDecimal64(10000.1, 18); -- { serverError 407 } +select toDecimal128(1000000000000000000000.1, 18); -- { serverError 407 } + +select toDecimal32(-10000.1, 6); -- { serverError 407 } +select toDecimal64(-10000.1, 18); -- { serverError 407 } +select toDecimal128(-1000000000000000000000.1, 18); -- { serverError 407 } + +select toDecimal32(2147483647.0 + 1.0, 0); -- { serverError 407 } +select toDecimal64(9223372036854775807.0, 0); -- { serverError 407 } +select toDecimal128(170141183460469231731687303715884105729.0, 0); -- { serverError 407 } + +select toDecimal32(-2147483647.0 - 1.0, 0); -- { serverError 407 } +select toDecimal64(-9223372036854775807.0, 0); -- { serverError 407 } +select toDecimal128(-170141183460469231731687303715884105729.0, 0); -- { serverError 407 }