ClickHouse/tests/queries/0_stateless/02184_default_table_engine.sql

121 lines
4.4 KiB
MySQL
Raw Normal View History

2022-01-31 17:11:15 +00:00
CREATE TABLE table_02184 (x UInt8); --{serverError 119}
SET default_table_engine = 'Log';
CREATE TABLE table_02184 (x UInt8);
2022-02-01 16:59:41 +00:00
SHOW CREATE TABLE table_02184;
2022-01-31 17:11:15 +00:00
DROP TABLE table_02184;
2022-02-10 20:35:03 +00:00
2022-01-31 17:11:15 +00:00
SET default_table_engine = 'MergeTree';
CREATE TABLE table_02184 (x UInt8); --{serverError 42}
CREATE TABLE table_02184 (x UInt8, PRIMARY KEY (x));
2022-02-01 16:59:41 +00:00
SHOW CREATE TABLE table_02184;
2022-01-31 17:11:15 +00:00
DROP TABLE table_02184;
2022-02-10 20:35:03 +00:00
CREATE TABLE test_optimize_exception (date Date) PARTITION BY toYYYYMM(date) ORDER BY date;
SHOW CREATE TABLE test_optimize_exception;
DROP TABLE test_optimize_exception;
2022-01-31 17:11:15 +00:00
CREATE TABLE table_02184 (x UInt8) PARTITION BY x; --{serverError 36}
CREATE TABLE table_02184 (x UInt8) ORDER BY x;
2022-02-01 16:59:41 +00:00
SHOW CREATE TABLE table_02184;
2022-01-31 17:11:15 +00:00
DROP TABLE table_02184;
2022-02-10 20:35:03 +00:00
2022-01-31 17:11:15 +00:00
CREATE TABLE table_02184 (x UInt8) PRIMARY KEY x;
2022-02-01 16:59:41 +00:00
SHOW CREATE TABLE table_02184;
2022-01-31 17:11:15 +00:00
DROP TABLE table_02184;
SET default_table_engine = 'Memory';
2022-02-07 12:38:54 +00:00
CREATE TABLE numbers1 AS SELECT number FROM numbers(10);
SHOW CREATE TABLE numbers1;
2022-02-07 12:38:54 +00:00
SELECT avg(number) FROM numbers1;
DROP TABLE numbers1;
2022-02-10 20:35:03 +00:00
SET default_table_engine = 'MergeTree';
CREATE TABLE numbers2 ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(10);
2022-02-07 12:38:54 +00:00
SELECT sum(number) FROM numbers2;
SHOW CREATE TABLE numbers2;
DROP TABLE numbers2;
2022-02-10 20:35:03 +00:00
2022-02-07 12:38:54 +00:00
CREATE TABLE numbers3 ENGINE = Log AS SELECT number FROM numbers(10);
SELECT sum(number) FROM numbers3;
SHOW CREATE TABLE numbers3;
DROP TABLE numbers3;
2022-02-10 20:35:03 +00:00
CREATE TABLE test_table (EventDate Date, CounterID UInt32, UserID UInt64, EventTime DateTime('Europe/Moscow'), UTCEventTime DateTime('UTC')) PARTITION BY EventDate PRIMARY KEY CounterID;
SET default_table_engine = 'Memory';
CREATE MATERIALIZED VIEW test_view (Rows UInt64, MaxHitTime DateTime('Europe/Moscow')) AS SELECT count() AS Rows, max(UTCEventTime) AS MaxHitTime FROM test_table;
CREATE MATERIALIZED VIEW test_view_filtered (EventDate Date, CounterID UInt32) POPULATE AS SELECT CounterID, EventDate FROM test_table WHERE EventDate < '2013-01-01';
2022-02-10 20:35:03 +00:00
SHOW CREATE TABLE test_view_filtered;
INSERT INTO test_table (EventDate, UTCEventTime) VALUES ('2014-01-02', '2014-01-02 03:04:06');
SELECT * FROM test_table;
SELECT * FROM test_view;
SELECT * FROM test_view_filtered;
DROP TABLE test_view;
2022-02-10 20:35:03 +00:00
DROP TABLE test_view_filtered;
SET default_table_engine = 'MergeTree';
CREATE MATERIALIZED VIEW test_view ORDER BY Rows AS SELECT count() AS Rows, max(UTCEventTime) AS MaxHitTime FROM test_table;
SET default_table_engine = 'Memory';
CREATE TABLE t1 AS test_view;
CREATE TABLE t2 ENGINE=Memory AS test_view;
SHOW CREATE TABLE t1;
SHOW CREATE TABLE t2;
DROP TABLE test_view;
DROP TABLE test_table;
DROP TABLE t1;
DROP TABLE t2;
CREATE DATABASE test_02184 ORDER BY kek; -- {serverError 80}
CREATE DATABASE test_02184 SETTINGS x=1; -- {serverError 80}
CREATE TABLE table_02184 (x UInt8, y int, PRIMARY KEY (x)) ENGINE=MergeTree PRIMARY KEY y; -- {clientError 36}
SET default_table_engine = 'MergeTree';
CREATE TABLE table_02184 (x UInt8, y int, PRIMARY KEY (x)) PRIMARY KEY y; -- {clientError 36}
CREATE TABLE mt (a UInt64, b Nullable(String), PRIMARY KEY (a, coalesce(b, 'test')), INDEX b_index b TYPE set(123) GRANULARITY 1);
SHOW CREATE TABLE mt;
SET default_table_engine = 'Log';
CREATE TABLE mt2 AS mt;
SHOW CREATE TABLE mt2;
DROP TABLE mt;
SET default_table_engine = 'Log';
CREATE TEMPORARY TABLE tmp (n int);
SHOW CREATE TEMPORARY TABLE tmp;
CREATE TEMPORARY TABLE tmp1 (n int) ENGINE=Memory;
CREATE TEMPORARY TABLE tmp2 (n int) ENGINE=Log; -- {serverError 80}
CREATE TEMPORARY TABLE tmp2 (n int) ORDER BY n; -- {serverError 80}
CREATE TEMPORARY TABLE tmp2 (n int, PRIMARY KEY (n)); -- {serverError 80}
CREATE TABLE log (n int);
SHOW CREATE log;
SET default_table_engine = 'MergeTree';
CREATE TABLE log1 AS log;
SHOW CREATE log1;
CREATE TABLE mem AS log1 ENGINE=Memory;
SHOW CREATE mem;
DROP TABLE log;
DROP TABLE log1;
DROP TABLE mem;
SET default_table_engine = 'None';
CREATE TABLE mem AS SELECT 1 as n; --{serverError 119}
SET default_table_engine = 'Memory';
CREATE TABLE mem ORDER BY n AS SELECT 1 as n; -- {serverError 36}
SET default_table_engine = 'MergeTree';
CREATE TABLE mt ORDER BY n AS SELECT 1 as n;
CREATE TABLE mem ENGINE=Memory AS SELECT 1 as n;
SHOW CREATE TABLE mt;
SHOW CREATE TABLE mem;
DROP TABLE mt;
DROP TABLE mem;
CREATE TABLE val AS values('n int', 1, 2);
CREATE TABLE val2 AS val;
CREATE TABLE log ENGINE=Log AS val;
SHOW CREATE TABLE val;
SHOW CREATE TABLE val2;
SHOW CREATE TABLE log;
DROP TABLE val;
DROP TABLE val2;
DROP TABLE log;