ClickHouse/tests/queries/0_stateless/01676_reinterpret_as.sql

43 lines
2.4 KiB
MySQL
Raw Normal View History

2021-01-31 15:32:47 +00:00
SELECT 'Into String';
SELECT reinterpret(49, 'String');
2021-01-31 15:32:47 +00:00
SELECT 'Into FixedString';
SELECT reinterpret(49, 'FixedString(1)');
SELECT reinterpret(49, 'FixedString(2)');
SELECT reinterpret(49, 'FixedString(3)');
SELECT reinterpret(49, 'FixedString(4)');
2021-01-31 15:32:47 +00:00
SELECT reinterpretAsFixedString(49);
SELECT 'Into Numeric Representable';
SELECT 'Integer and Integer types';
SELECT reinterpret(257, 'UInt8'), reinterpretAsUInt8(257);
SELECT reinterpret(257, 'Int8'), reinterpretAsInt8(257);
SELECT reinterpret(257, 'UInt16'), reinterpretAsUInt16(257);
SELECT reinterpret(257, 'Int16'), reinterpretAsInt16(257);
SELECT reinterpret(257, 'UInt32'), reinterpretAsUInt32(257);
SELECT reinterpret(257, 'Int32'), reinterpretAsInt32(257);
SELECT reinterpret(257, 'UInt64'), reinterpretAsUInt64(257);
SELECT reinterpret(257, 'Int64'), reinterpretAsInt64(257);
SELECT reinterpret(257, 'Int128'), reinterpretAsInt128(257);
SELECT reinterpret(257, 'UInt256'), reinterpretAsUInt256(257);
SELECT reinterpret(257, 'Int256'), reinterpretAsInt256(257);
2021-01-31 15:32:47 +00:00
SELECT 'Integer and Float types';
SELECT reinterpret(toFloat32(0.2), 'UInt32'), reinterpretAsUInt32(toFloat32(0.2));
SELECT reinterpret(toFloat64(0.2), 'UInt64'), reinterpretAsUInt64(toFloat64(0.2));
2021-01-31 15:32:47 +00:00
SELECT reinterpretAsFloat32(a), reinterpretAsUInt32(toFloat32(0.2)) as a;
SELECT reinterpretAsFloat64(a), reinterpretAsUInt64(toFloat64(0.2)) as a;
SELECT 'Integer and String types';
SELECT reinterpret(a, 'String'), reinterpretAsString(a), reinterpretAsUInt8('1') as a;
SELECT reinterpret(a, 'String'), reinterpretAsString(a), reinterpretAsUInt8('11') as a;
SELECT reinterpret(a, 'String'), reinterpretAsString(a), reinterpretAsUInt16('11') as a;
SELECT 'Dates';
SELECT reinterpret(0, 'Date'), reinterpret('', 'Date');
2021-07-18 14:56:45 +00:00
SELECT reinterpret(0, 'DateTime(''Europe/Moscow'')'), reinterpret('', 'DateTime(''Europe/Moscow'')');
SELECT reinterpret(0, 'DateTime64(3, ''Europe/Moscow'')'), reinterpret('', 'DateTime64(3, ''Europe/Moscow'')');
SELECT 'Decimals';
SELECT reinterpret(toDecimal32(5, 2), 'Decimal32(2)'), reinterpret('1', 'Decimal32(2)');
SELECT reinterpret(toDecimal64(5, 2), 'Decimal64(2)'), reinterpret('1', 'Decimal64(2)');;
SELECT reinterpret(toDecimal128(5, 2), 'Decimal128(2)'), reinterpret('1', 'Decimal128(2)');
SELECT reinterpret(toDecimal256(5, 2), 'Decimal256(2)'), reinterpret('1', 'Decimal256(2)');
SELECT reinterpret(toDateTime64(0, 0), 'Decimal64(2)');
2021-02-17 09:53:12 +00:00
SELECT 'ReinterpretErrors';
SELECT reinterpret('123', 'FixedString(1)'); -- {serverError 43}