From f71eb3671926f4c840d230018029033824f7bb97 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 7 Jun 2018 23:37:16 +0300 Subject: [PATCH] Added test [#CLICKHOUSE-3764] --- .../queries/0_stateless/00642_cast.reference | 12 +++++ dbms/tests/queries/0_stateless/00642_cast.sql | 46 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00642_cast.reference create mode 100644 dbms/tests/queries/0_stateless/00642_cast.sql diff --git a/dbms/tests/queries/0_stateless/00642_cast.reference b/dbms/tests/queries/0_stateless/00642_cast.reference new file mode 100644 index 00000000000..fcfb7325442 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00642_cast.reference @@ -0,0 +1,12 @@ +hello +hello +hello +hello +hello +hello +hello +hello +CREATE TABLE test.cast ( x UInt8, e Enum8('hello' = 1, 'world' = 2) DEFAULT CAST(x, 'Enum8(\'hello\' = 1, \'world\' = 2)')) ENGINE = MergeTree ORDER BY e SETTINGS index_granularity = 8192 +x UInt8 +e Enum8(\'hello\' = 1, \'world\' = 2) DEFAULT CAST(x, \'Enum8(\\\'hello\\\' = 1, \\\'world\\\' = 2)\') +1 hello diff --git a/dbms/tests/queries/0_stateless/00642_cast.sql b/dbms/tests/queries/0_stateless/00642_cast.sql new file mode 100644 index 00000000000..0e50d4c7e53 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00642_cast.sql @@ -0,0 +1,46 @@ +SELECT CAST(1 AS Enum8('hello' = 1, 'world' = 2)); +SELECT cast(1 AS Enum8('hello' = 1, 'world' = 2)); + +SELECT CAST(1, 'Enum8(\'hello\' = 1, \'world\' = 2)'); +SELECT cast(1, 'Enum8(\'hello\' = 1, \'world\' = 2)'); + +SELECT CAST(1 AS Enum8( + 'hello' = 1, + 'world' = 2)); + +SELECT cast(1 AS Enum8( + 'hello' = 1, + 'world' = 2)); + +SELECT CAST(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)'); +SELECT cast(1, 'Enum8(\'hello\' = 1,\n\t\'world\' = 2)'); + +DROP TABLE IF EXISTS test.cast; +CREATE TABLE test.cast +( + x UInt8, + e Enum8 + ( + 'hello' = 1, + 'world' = 2 + ) + DEFAULT + CAST + ( + x + AS + Enum8 + ( + 'hello' = 1, + 'world' = 2 + ) + ) +) ENGINE = MergeTree ORDER BY e; + +SHOW CREATE TABLE test.cast FORMAT TSVRaw; +DESC TABLE test.cast; + +INSERT INTO test.cast (x) VALUES (1); +SELECT * FROM test.cast; + +DROP TABLE test.cast;