ClickHouse/tests/queries/0_stateless/01322_cast_keep_nullable.sql
Alexey Milovidov 06405531a1 Update tests
2021-01-05 02:58:16 +03:00

19 lines
838 B
SQL

SET cast_keep_nullable = 0;
SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x);
SELECT CAST(toNullable(toInt8(0)) AS Int32) as x, toTypeName(x);
SET cast_keep_nullable = 1;
SELECT CAST(toNullable(toInt32(1)) AS Int32) as x, toTypeName(x);
SELECT CAST(toNullable(toInt8(1)) AS Int32) as x, toTypeName(x);
SELECT CAST(toNullable(toFloat32(2)), 'Float32') as x, toTypeName(x);
SELECT CAST(toNullable(toFloat32(2)), 'UInt8') as x, toTypeName(x);
SELECT CAST(if(1 = 1, toNullable(toInt8(3)), NULL) AS Int32) as x, toTypeName(x);
SELECT CAST(if(1 = 0, toNullable(toInt8(3)), NULL) AS Int32) as x, toTypeName(x);
SELECT CAST(a, 'Int32') as x, toTypeName(x) FROM (SELECT materialize(CAST(42, 'Nullable(UInt8)')) AS a);
SELECT CAST(a, 'Int32') as x, toTypeName(x) FROM (SELECT materialize(CAST(NULL, 'Nullable(UInt8)')) AS a);