提交 ab6652da 编写于 作者: I Ivan Lezhankin

Fix some tests

上级 f24a4ef9
d Date
k UInt64
i32 Int32
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 10 42
d Date
k UInt64
i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String)) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 8 40 [1,2,3] ['12','13','14']
2015-01-01 10 42 [] []
d Date
......@@ -17,7 +17,7 @@ i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 7 39 [10,20,30] ['120','130','140'] ['2000-01-01','2000-01-01','2000-01-03']
2015-01-01 8 40 [1,2,3] ['12','13','14'] ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 10 42 [] [] []
......@@ -28,7 +28,7 @@ n.ui8 Array(UInt8)
n.s Array(String)
n.d Array(Date)
s String DEFAULT \'0\'
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date), `s` String DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `n.d` Array(Date), `s` String DEFAULT \'0\') ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] ['2000-01-01','2000-01-01','2000-01-03'] 100500
2015-01-01 7 39 [10,20,30] ['120','130','140'] ['2000-01-01','2000-01-01','2000-01-03'] 0
2015-01-01 8 40 [1,2,3] ['12','13','14'] ['0000-00-00','0000-00-00','0000-00-00'] 0
......@@ -39,7 +39,7 @@ i32 Int32
n.ui8 Array(UInt8)
n.s Array(String)
s Int64
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` Int64) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0
......@@ -51,7 +51,7 @@ n.ui8 Array(UInt8)
n.s Array(String)
s UInt32
n.d Array(Date)
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32, `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.ui8` Array(UInt8), `n.s` Array(String), `s` UInt32, `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 [10,20,30] ['asd','qwe','qwe'] 100500 ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 7 39 [10,20,30] ['120','130','140'] 0 ['0000-00-00','0000-00-00','0000-00-00']
2015-01-01 8 40 [1,2,3] ['12','13','14'] 0 ['0000-00-00','0000-00-00','0000-00-00']
......@@ -65,7 +65,7 @@ k UInt64
i32 Int32
n.s Array(String)
s UInt32
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.s` Array(String), `s` UInt32) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `n.s` Array(String), `s` UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 ['asd','qwe','qwe'] 100500
2015-01-01 7 39 ['120','130','140'] 0
2015-01-01 8 40 ['12','13','14'] 0
......@@ -74,7 +74,7 @@ d Date
k UInt64
i32 Int32
s UInt32
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500
2015-01-01 7 39 0
2015-01-01 8 40 0
......@@ -85,7 +85,7 @@ i32 Int32
s UInt32
n.s Array(String)
n.d Array(Date)
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32, `n.s` Array(String), `n.d` Array(Date)) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500 [] []
2015-01-01 7 39 0 [] []
2015-01-01 8 40 0 [] []
......@@ -94,7 +94,7 @@ d Date
k UInt64
i32 Int32
s UInt32
CREATE TABLE test.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
CREATE TABLE default.alter_00061 (`d` Date, `k` UInt64, `i32` Int32, `s` UInt32) ENGINE = MergeTree(d, k, 8192)
2015-01-01 6 38 100500
2015-01-01 7 39 0
2015-01-01 8 40 0
......
DROP TABLE IF EXISTS test.alter_00061;
CREATE TABLE test.alter_00061 (d Date, k UInt64, i32 Int32) ENGINE=MergeTree(d, k, 8192);
DROP TABLE IF EXISTS alter_00061;
CREATE TABLE alter_00061 (d Date, k UInt64, i32 Int32) ENGINE=MergeTree(d, k, 8192);
INSERT INTO test.alter_00061 VALUES ('2015-01-01', 10, 42);
INSERT INTO alter_00061 VALUES ('2015-01-01', 10, 42);
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 ADD COLUMN n Nested(ui8 UInt8, s String);
INSERT INTO test.alter_00061 VALUES ('2015-01-01', 8, 40, [1,2,3], ['12','13','14']);
ALTER TABLE alter_00061 ADD COLUMN n Nested(ui8 UInt8, s String);
INSERT INTO alter_00061 VALUES ('2015-01-01', 8, 40, [1,2,3], ['12','13','14']);
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 ADD COLUMN `n.d` Array(Date);
INSERT INTO test.alter_00061 VALUES ('2015-01-01', 7, 39, [10,20,30], ['120','130','140'],['2000-01-01','2000-01-01','2000-01-03']);
ALTER TABLE alter_00061 ADD COLUMN `n.d` Array(Date);
INSERT INTO alter_00061 VALUES ('2015-01-01', 7, 39, [10,20,30], ['120','130','140'],['2000-01-01','2000-01-01','2000-01-03']);
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 ADD COLUMN s String DEFAULT '0';
INSERT INTO test.alter_00061 VALUES ('2015-01-01', 6,38,[10,20,30],['asd','qwe','qwe'],['2000-01-01','2000-01-01','2000-01-03'],'100500');
ALTER TABLE alter_00061 ADD COLUMN s String DEFAULT '0';
INSERT INTO alter_00061 VALUES ('2015-01-01', 6,38,[10,20,30],['asd','qwe','qwe'],['2000-01-01','2000-01-01','2000-01-03'],'100500');
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 DROP COLUMN `n.d`, MODIFY COLUMN s Int64;
ALTER TABLE alter_00061 DROP COLUMN `n.d`, MODIFY COLUMN s Int64;
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 ADD COLUMN `n.d` Array(Date), MODIFY COLUMN s UInt32;
ALTER TABLE alter_00061 ADD COLUMN `n.d` Array(Date), MODIFY COLUMN s UInt32;
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
OPTIMIZE TABLE test.alter_00061;
OPTIMIZE TABLE alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 DROP COLUMN n.ui8, DROP COLUMN n.d;
ALTER TABLE alter_00061 DROP COLUMN n.ui8, DROP COLUMN n.d;
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 DROP COLUMN n.s;
ALTER TABLE alter_00061 DROP COLUMN n.s;
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 ADD COLUMN n.s Array(String), ADD COLUMN n.d Array(Date);
ALTER TABLE alter_00061 ADD COLUMN n.s Array(String), ADD COLUMN n.d Array(Date);
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
ALTER TABLE test.alter_00061 DROP COLUMN n;
ALTER TABLE alter_00061 DROP COLUMN n;
DESC TABLE test.alter_00061;
SHOW CREATE TABLE test.alter_00061;
SELECT * FROM test.alter_00061 ORDER BY k;
DESC TABLE alter_00061;
SHOW CREATE TABLE alter_00061;
SELECT * FROM alter_00061 ORDER BY k;
DROP TABLE test.alter_00061;
DROP TABLE alter_00061;
......@@ -14,3 +14,6 @@ CREATE TABLE check_query_log (N UInt32,S String) Engine = Log;
INSERT INTO check_query_log VALUES (1, 'A'), (2, 'B'), (3, 'C')
CHECK TABLE check_query_log;
DROP TABLE check_query_log;
DROP TABLE check_query_tiny_log;
DROP TABLE IF EXISTS test.join;
DROP TABLE IF EXISTS join;
CREATE TABLE test.join (k UInt64, s String) ENGINE = Join(ANY, LEFT, k);
CREATE TABLE join (k UInt64, s String) ENGINE = Join(ANY, LEFT, k);
USE test;
INSERT INTO test.join VALUES (1, 'abc'), (2, 'def');
INSERT INTO join VALUES (1, 'abc'), (2, 'def');
SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k;
INSERT INTO test.join VALUES (6, 'ghi');
INSERT INTO join VALUES (6, 'ghi');
SELECT k, s FROM (SELECT number AS k FROM system.numbers LIMIT 10) ANY LEFT JOIN join USING k;
USE default;
DROP TABLE test.join;
DROP TABLE join;
DROP TABLE IF EXISTS mt_00168;
DROP TABLE IF EXISTS mt_00168_buffer;
CREATE TABLE mt_00168 (EventDate Date, UTCEventTime DateTime, MoscowEventDate Date DEFAULT toDate(UTCEventTime)) ENGINE = MergeTree(EventDate, UTCEventTime, 8192);
CREATE TABLE mt_00168_buffer AS mt_00168 ENGINE = Buffer(test, mt_00168, 16, 10, 100, 10000, 1000000, 10000000, 100000000);
CREATE TABLE mt_00168_buffer AS mt_00168 ENGINE = Buffer(currentDatabase(), mt_00168, 16, 10, 100, 10000, 1000000, 10000000, 100000000);
DESC TABLE mt_00168;
DESC TABLE mt_00168_buffer;
INSERT INTO mt_00168 (EventDate, UTCEventTime) VALUES ('2015-06-09', '2015-06-09 01:02:03');
......
DROP TABLE IF EXISTS test.numbers_memory;
CREATE TABLE test.numbers_memory AS system.numbers ENGINE = Memory;
INSERT INTO test.numbers_memory SELECT number FROM system.numbers LIMIT 100;
SELECT DISTINCT number FROM remote('127.0.0.{2,3}', test.numbers_memory) ORDER BY number LIMIT 10;
DROP TABLE test.numbers_memory;
DROP TABLE IF EXISTS numbers_memory;
CREATE TABLE numbers_memory AS system.numbers ENGINE = Memory;
INSERT INTO numbers_memory SELECT number FROM system.numbers LIMIT 100;
SELECT DISTINCT number FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_memory) ORDER BY number LIMIT 10;
DROP TABLE numbers_memory;
......@@ -6,18 +6,18 @@ SELECT quantileTimingWeighted(0.5)(number, 1) FROM (SELECT number FROM system.nu
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 1) FROM (SELECT number FROM system.numbers LIMIT 1001);
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, number) FROM (SELECT number FROM system.numbers LIMIT 1001);
DROP TABLE IF EXISTS test.numbers_1001;
CREATE TABLE test.numbers_1001 (number UInt64) ENGINE = Memory;
DROP TABLE IF EXISTS numbers_1001;
CREATE TABLE numbers_1001 (number UInt64) ENGINE = Memory;
SET min_insert_block_size_rows = 0, min_insert_block_size_bytes = 0;
SET max_block_size = 10;
INSERT INTO test.numbers_1001 SELECT number FROM system.numbers LIMIT 1001;
INSERT INTO numbers_1001 SELECT number FROM system.numbers LIMIT 1001;
SELECT quantileExactWeighted(0.5)(number, 1) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantilesExactWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 1) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantilesExactWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, number) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantileExactWeighted(0.5)(number, 1) FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_1001);
SELECT quantilesExactWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 1) FROM remote('127.0.0.{2,3}', numbers_1001);
SELECT quantilesExactWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, number) FROM remote('127.0.0.{2,3}', numbers_1001);
SELECT quantileTimingWeighted(0.5)(number, 1) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 1) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, number) FROM remote('127.0.0.{2,3}', test.numbers_1001);
SELECT quantileTimingWeighted(0.5)(number, 1) FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_1001);
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, 1) FROM remote('127.0.0.{2,3}', numbers_1001);
SELECT quantilesTimingWeighted(0, 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.99, 0.999, 1)(number, number) FROM remote('127.0.0.{2,3}', numbers_1001);
DROP TABLE test.numbers_1001;
DROP TABLE numbers_1001;
DROP TABLE IF EXISTS test.numbers_10_00290;
DROP TABLE IF EXISTS numbers_10_00290;
SET max_block_size = 1000;
CREATE TABLE test.numbers_10_00290 ENGINE = Log AS SELECT * FROM system.numbers LIMIT 10000;
CREATE TABLE numbers_10_00290 ENGINE = Log AS SELECT * FROM system.numbers LIMIT 10000;
SET distributed_aggregation_memory_efficient = 1, group_by_two_level_threshold = 5000;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', test.numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
SELECT concat(toString(number), arrayStringConcat(arrayMap(x -> '.', range(number % 10)))) AS k FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00290) WHERE number < (randConstant() % 2 ? 4999 : 10000) GROUP BY k ORDER BY k LIMIT 10;
DROP TABLE test.numbers_10_00290;
DROP TABLE numbers_10_00290;
SELECT '----- NULL value -----';
SELECT NULL;
......@@ -148,18 +147,18 @@ SELECT col1 FROM test1_00395 WHERE col1 IS NULL;
SELECT '----- if -----';
DROP TABLE IF EXISTS test.test1_00395;
CREATE TABLE test.test1_00395 (col1 Nullable(String)) ENGINE=TinyLog;
INSERT INTO test.test1_00395 VALUES ('a'), ('b'), ('c'), (NULL);
DROP TABLE IF EXISTS test1_00395;
CREATE TABLE test1_00395 (col1 Nullable(String)) ENGINE=TinyLog;
INSERT INTO test1_00395 VALUES ('a'), ('b'), ('c'), (NULL);
SELECT col1, if(col1 IN ('a' ,'b'), 1, 0) AS t, toTypeName(t) FROM test.test1_00395;
SELECT col1, if(col1 IN ('a' ,'b'), NULL, 0) AS t, toTypeName(t) FROM test.test1_00395;
SELECT col1, if(col1 IN ('a' ,'b'), 1, 0) AS t, toTypeName(t) FROM test1_00395;
SELECT col1, if(col1 IN ('a' ,'b'), NULL, 0) AS t, toTypeName(t) FROM test1_00395;
SELECT '----- case when -----';
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 ELSE 0 END AS t, toTypeName(t) FROM test.test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN NULL ELSE 0 END AS t, toTypeName(t) FROM test.test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 END AS t, toTypeName(t) FROM test.test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 ELSE 0 END AS t, toTypeName(t) FROM test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN NULL ELSE 0 END AS t, toTypeName(t) FROM test1_00395;
SELECT col1, CASE WHEN col1 IN ('a' ,'b') THEN 1 END AS t, toTypeName(t) FROM test1_00395;
SELECT '----- multiIf -----';
......
......@@ -9,7 +9,7 @@ Sum before DETACH PARTITION:
Sum after DETACH PARTITION:
0
system.detached_parts after DETACH PARTITION:
test not_partitioned all all_1_2_1 1 2 1
default not_partitioned all all_1_2_1 1 2 1
*** Partitioned by week ***
Parts before OPTIMIZE:
1999-12-27 19991227_1_1_0
......
......@@ -4,3 +4,4 @@ insert into function remote('127.0.0.2', currentDatabase(), tab) values (1);
insert into function remote('127.0.0.{2|3}', currentDatabase(), tab) values (2);
insert into function remote('127.0.0.{2|3|4}', currentDatabase(), tab) values (3);
select * from tab order by val;
drop table tab;
DROP TABLE IF EXISTS test.numbers1;
DROP TABLE IF EXISTS test.numbers2;
DROP TABLE IF EXISTS test.numbers3;
DROP TABLE IF EXISTS test.numbers4;
DROP TABLE IF EXISTS test.numbers5;
DROP TABLE IF EXISTS numbers1;
DROP TABLE IF EXISTS numbers2;
DROP TABLE IF EXISTS numbers3;
DROP TABLE IF EXISTS numbers4;
DROP TABLE IF EXISTS numbers5;
CREATE TABLE test.numbers1 ENGINE = StripeLog AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers2 ENGINE = TinyLog AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers3 ENGINE = Log AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers4 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers5 ENGINE = MergeTree ORDER BY number AS SELECT number FROM numbers(1000);
CREATE TABLE numbers1 ENGINE = StripeLog AS SELECT number FROM numbers(1000);
CREATE TABLE numbers2 ENGINE = TinyLog AS SELECT number FROM numbers(1000);
CREATE TABLE numbers3 ENGINE = Log AS SELECT number FROM numbers(1000);
CREATE TABLE numbers4 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE numbers5 ENGINE = MergeTree ORDER BY number AS SELECT number FROM numbers(1000);
SELECT count() FROM merge(test, '^numbers\\d+$');
SELECT DISTINCT count() FROM merge(test, '^numbers\\d+$') GROUP BY number;
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$');
SELECT DISTINCT count() FROM merge(currentDatabase(), '^numbers\\d+$') GROUP BY number;
SET max_rows_to_read = 1000;
SET max_threads = 'auto';
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'numbers1';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'numbers1';
SET max_threads = 1;
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'numbers2';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'numbers2';
SET max_threads = 10;
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'numbers3';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'numbers3';
SET max_rows_to_read = 1;
SET max_threads = 'auto';
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'non_existing';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'non_existing';
SET max_threads = 1;
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'non_existing';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'non_existing';
SET max_threads = 10;
SELECT count() FROM merge(test, '^numbers\\d+$') WHERE _table = 'non_existing';
SELECT count() FROM merge(currentDatabase(), '^numbers\\d+$') WHERE _table = 'non_existing';
DROP TABLE test.numbers1;
DROP TABLE test.numbers2;
DROP TABLE test.numbers3;
DROP TABLE test.numbers4;
DROP TABLE test.numbers5;
DROP TABLE numbers1;
DROP TABLE numbers2;
DROP TABLE numbers3;
DROP TABLE numbers4;
DROP TABLE numbers5;
DROP TABLE IF EXISTS test.numbers1;
DROP TABLE IF EXISTS test.numbers2;
DROP TABLE IF EXISTS numbers1;
DROP TABLE IF EXISTS numbers2;
CREATE TABLE test.numbers1 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers2 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE numbers1 ENGINE = Memory AS SELECT number FROM numbers(1000);
CREATE TABLE numbers2 ENGINE = Memory AS SELECT number FROM numbers(1000);
SELECT * FROM merge(test, '^numbers\\d+$') SAMPLE 0.1; -- { serverError 141 }
SELECT * FROM merge(currentDatabase(), '^numbers\\d+$') SAMPLE 0.1; -- { serverError 141 }
DROP TABLE test.numbers1;
DROP TABLE test.numbers2;
DROP TABLE numbers1;
DROP TABLE numbers2;
CREATE TABLE test.numbers1 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
CREATE TABLE test.numbers2 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
CREATE TABLE numbers1 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
CREATE TABLE numbers2 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000);
SELECT * FROM merge(test, '^numbers\\d+$') SAMPLE 0.01;
SELECT * FROM merge(currentDatabase(), '^numbers\\d+$') SAMPLE 0.01;
DROP TABLE test.numbers1;
DROP TABLE test.numbers2;
DROP TABLE numbers1;
DROP TABLE numbers2;
......@@ -21,42 +21,42 @@ SELECT id\nFROM \n(\n SELECT arrayJoin([1, 2, 3]) AS id\n WHERE id = 1\n)
1
SELECT \n id, \n subquery\nFROM \n(\n SELECT \n 1 AS id, \n CAST(1, \'UInt8\') AS subquery\n WHERE subquery = 1\n) \nWHERE subquery = 1
1 1
SELECT \n a, \n b\nFROM \n(\n SELECT \n toUInt64(sum(id) AS b) AS a, \n b\n FROM test.test_00597 \n HAVING a = 3\n) \nWHERE a = 3
SELECT \n a, \n b\nFROM \n(\n SELECT \n toUInt64(sum(id) AS b) AS a, \n b\n FROM default.test_00597 \n HAVING a = 3\n) \nWHERE a = 3
3 3
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n name, \n value, \n min(id) AS id\n FROM test.test_00597 \n GROUP BY \n date, \n name, \n value\n HAVING id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n name, \n value, \n min(id) AS id\n FROM default.test_00597 \n GROUP BY \n date, \n name, \n value\n HAVING id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n a, \n b\nFROM \n(\n SELECT \n toUInt64(sum(id) AS b) AS a, \n b\n FROM test.test_00597 AS table_alias \n HAVING b = 3\n) AS outer_table_alias \nWHERE b = 3
SELECT \n a, \n b\nFROM \n(\n SELECT \n toUInt64(sum(id) AS b) AS a, \n b\n FROM default.test_00597 AS table_alias \n HAVING b = 3\n) AS outer_table_alias \nWHERE b = 3
3 3
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) AS b \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) AS b \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n) AS b \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n) AS b \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) AS a \n WHERE id = 1\n) AS b \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) AS a \n WHERE id = 1\n) AS b \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n id, \n date, \n value\nFROM \n(\n SELECT \n id, \n date, \n min(value) AS value\n FROM test.test_00597 \n WHERE id = 1\n GROUP BY \n id, \n date\n) \nWHERE id = 1
SELECT \n id, \n date, \n value\nFROM \n(\n SELECT \n id, \n date, \n min(value) AS value\n FROM default.test_00597 \n WHERE id = 1\n GROUP BY \n id, \n date\n) \nWHERE id = 1
1 2000-01-01 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n UNION ALL\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n UNION ALL\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test_00597 \n) USING (id)\nWHERE id = 1
SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM default.test_00597 \n) USING (id)\nWHERE id = 1
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN test.test_00597 USING (id)\nWHERE value = 1
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN default.test_00597 USING (id)\nWHERE value = 1
1 2000-01-01 test string 1 1
SELECT value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN test.test_00597 AS b USING (id)\nWHERE value = 1
SELECT value\nFROM \n(\n SELECT toInt8(1) AS id\n) \nANY LEFT JOIN default.test_00597 AS b USING (id)\nWHERE value = 1
1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) \n ANY LEFT JOIN \n (\n SELECT *\n FROM test.test_00597 \n ) USING (id)\n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n date, \n name, \n value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) \n ANY LEFT JOIN \n (\n SELECT *\n FROM default.test_00597 \n ) USING (id)\n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1
SELECT \n date, \n id, \n name, \n value, \n b.date, \n b.name, \n b.value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test_00597 \n) AS b USING (id)\nWHERE b.id = 1
SELECT \n date, \n id, \n name, \n value, \n b.date, \n b.name, \n b.value\nFROM \n(\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n) \nANY LEFT JOIN \n(\n SELECT *\n FROM default.test_00597 \n) AS b USING (id)\nWHERE b.id = 1
2000-01-01 1 test string 1 1 2000-01-01 test string 1 1
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT \n toInt8(1) AS id, \n toDate(\'2000-01-01\') AS date\n FROM system.numbers \n LIMIT 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM test.test_00597 \n) AS b USING (date, id)\nWHERE b.date = toDate(\'2000-01-01\')
SELECT \n id, \n date, \n name, \n value\nFROM \n(\n SELECT \n toInt8(1) AS id, \n toDate(\'2000-01-01\') AS date\n FROM system.numbers \n LIMIT 1\n) \nANY LEFT JOIN \n(\n SELECT *\n FROM default.test_00597 \n) AS b USING (date, id)\nWHERE b.date = toDate(\'2000-01-01\')
1 2000-01-01 test string 1 1
SELECT \n date, \n id, \n name, \n value, \n `b.date`, \n `b.id`, \n `b.name`, \n `b.value`\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n b.date, \n b.id, \n b.name, \n b.value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM test.test_00597 \n WHERE id = 1\n ) AS a \n ANY LEFT JOIN \n (\n SELECT *\n FROM test.test_00597 \n ) AS b ON id = b.id\n WHERE id = 1\n) \nWHERE id = 1
SELECT \n date, \n id, \n name, \n value, \n `b.date`, \n `b.id`, \n `b.name`, \n `b.value`\nFROM \n(\n SELECT \n date, \n id, \n name, \n value, \n b.date, \n b.id, \n b.name, \n b.value\n FROM \n (\n SELECT \n date, \n id, \n name, \n value\n FROM default.test_00597 \n WHERE id = 1\n ) AS a \n ANY LEFT JOIN \n (\n SELECT *\n FROM default.test_00597 \n ) AS b ON id = b.id\n WHERE id = 1\n) \nWHERE id = 1
2000-01-01 1 test string 1 1 2000-01-01 1 test string 1 1
SET send_logs_level = 'none';
DROP TABLE IF EXISTS test.test_00597;
DROP TABLE IF EXISTS test.test_view_00597;
DROP TABLE IF EXISTS test_00597;
DROP TABLE IF EXISTS test_view_00597;
CREATE TABLE test.test_00597(date Date, id Int8, name String, value Int64) ENGINE = MergeTree(date, (id, date), 8192);
CREATE VIEW test.test_view_00597 AS SELECT * FROM test.test_00597;
CREATE TABLE test_00597(date Date, id Int8, name String, value Int64) ENGINE = MergeTree(date, (id, date), 8192);
CREATE VIEW test_view_00597 AS SELECT * FROM test_00597;
INSERT INTO test.test_00597 VALUES('2000-01-01', 1, 'test string 1', 1);
INSERT INTO test.test_00597 VALUES('2000-01-01', 2, 'test string 2', 2);
INSERT INTO test_00597 VALUES('2000-01-01', 1, 'test string 1', 1);
INSERT INTO test_00597 VALUES('2000-01-01', 2, 'test string 2', 2);
SET enable_optimize_predicate_expression = 1;
SET enable_debug_queries = 1;
......@@ -16,7 +16,7 @@ SELECT '-------No need for predicate optimization, but still works-------';
SELECT 1;
SELECT 1 AS id WHERE id = 1;
SELECT arrayJoin([1,2,3]) AS id WHERE id = 1;
SELECT * FROM test.test_00597 WHERE id = 1;
SELECT * FROM test_00597 WHERE id = 1;
SELECT '-------Forbid push down-------';
......@@ -57,76 +57,76 @@ ANALYZE SELECT * FROM (SELECT 1 AS id, (SELECT 1) as subquery) WHERE subquery =
SELECT * FROM (SELECT 1 AS id, (SELECT 1) as subquery) WHERE subquery = 1;
-- Optimize predicate expressions using tables
ANALYZE SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test.test_00597) WHERE a = 3;
SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test.test_00597) WHERE a = 3;
ANALYZE SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test_00597) WHERE a = 3;
SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test_00597) WHERE a = 3;
ANALYZE SELECT date, id, name, value FROM (SELECT date, name, value, min(id) AS id FROM test.test_00597 GROUP BY date, name, value) WHERE id = 1;
SELECT date, id, name, value FROM (SELECT date, name, value, min(id) AS id FROM test.test_00597 GROUP BY date, name, value) WHERE id = 1;
ANALYZE SELECT date, id, name, value FROM (SELECT date, name, value, min(id) AS id FROM test_00597 GROUP BY date, name, value) WHERE id = 1;
SELECT date, id, name, value FROM (SELECT date, name, value, min(id) AS id FROM test_00597 GROUP BY date, name, value) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test.test_00597 AS table_alias) AS outer_table_alias WHERE outer_table_alias.b = 3;
SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test.test_00597 AS table_alias) AS outer_table_alias WHERE outer_table_alias.b = 3;
ANALYZE SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test_00597 AS table_alias) AS outer_table_alias WHERE outer_table_alias.b = 3;
SELECT * FROM (SELECT toUInt64(b) AS a, sum(id) AS b FROM test_00597 AS table_alias) AS outer_table_alias WHERE outer_table_alias.b = 3;
-- Optimize predicate expression with asterisk
ANALYZE SELECT * FROM (SELECT * FROM test.test_00597) WHERE id = 1;
SELECT * FROM (SELECT * FROM test.test_00597) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM test_00597) WHERE id = 1;
SELECT * FROM (SELECT * FROM test_00597) WHERE id = 1;
-- Optimize predicate expression with asterisk and nested subquery
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597)) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597)) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597)) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597)) WHERE id = 1;
-- Optimize predicate expression with qualified asterisk
ANALYZE SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test_00597) AS b) WHERE id = 1;
SELECT * FROM (SELECT b.* FROM (SELECT * FROM test.test_00597) AS b) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT b.* FROM (SELECT * FROM test_00597) AS b) WHERE id = 1;
SELECT * FROM (SELECT b.* FROM (SELECT * FROM test_00597) AS b) WHERE id = 1;
-- Optimize predicate expression without asterisk
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM test.test_00597) WHERE id = 1;
SELECT * FROM (SELECT date, id, name, value FROM test.test_00597) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM test_00597) WHERE id = 1;
SELECT * FROM (SELECT date, id, name, value FROM test_00597) WHERE id = 1;
-- Optimize predicate expression without asterisk and contains nested subquery
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test_00597)) WHERE id = 1;
SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test.test_00597)) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test_00597)) WHERE id = 1;
SELECT * FROM (SELECT date, id, name, value FROM (SELECT date, id, name, value FROM test_00597)) WHERE id = 1;
-- Optimize predicate expression with qualified
ANALYZE SELECT * FROM (SELECT * FROM test.test_00597) AS b WHERE b.id = 1;
SELECT * FROM (SELECT * FROM test.test_00597) AS b WHERE b.id = 1;
ANALYZE SELECT * FROM (SELECT * FROM test_00597) AS b WHERE b.id = 1;
SELECT * FROM (SELECT * FROM test_00597) AS b WHERE b.id = 1;
-- Optimize predicate expression with qualified and nested subquery
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) AS a) AS b WHERE b.id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) AS a) AS b WHERE b.id = 1;
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) AS a) AS b WHERE b.id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) AS a) AS b WHERE b.id = 1;
-- Optimize predicate expression with aggregate function
ANALYZE SELECT * FROM (SELECT id, date, min(value) AS value FROM test.test_00597 GROUP BY id, date) WHERE id = 1;
SELECT * FROM (SELECT id, date, min(value) AS value FROM test.test_00597 GROUP BY id, date) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT id, date, min(value) AS value FROM test_00597 GROUP BY id, date) WHERE id = 1;
SELECT * FROM (SELECT id, date, min(value) AS value FROM test_00597 GROUP BY id, date) WHERE id = 1;
-- Optimize predicate expression with union all query
ANALYZE SELECT * FROM (SELECT * FROM test.test_00597 UNION ALL SELECT * FROM test.test_00597) WHERE id = 1;
SELECT * FROM (SELECT * FROM test.test_00597 UNION ALL SELECT * FROM test.test_00597) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM test_00597 UNION ALL SELECT * FROM test_00597) WHERE id = 1;
SELECT * FROM (SELECT * FROM test_00597 UNION ALL SELECT * FROM test_00597) WHERE id = 1;
-- Optimize predicate expression with join query
ANALYZE SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) USING id WHERE id = 1;
SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) USING id WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) USING id WHERE id = 1;
SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) USING id WHERE id = 1;
ANALYZE SELECT * FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test.test_00597 USING id WHERE value = 1;
SELECT * FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test.test_00597 USING id WHERE value = 1;
ANALYZE SELECT * FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test_00597 USING id WHERE value = 1;
SELECT * FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test_00597 USING id WHERE value = 1;
-- FIXME: no support for aliased tables for now.
ANALYZE SELECT b.value FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test.test_00597 AS b USING id WHERE value = 1;
SELECT b.value FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test.test_00597 AS b USING id WHERE value = 1;
ANALYZE SELECT b.value FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test_00597 AS b USING id WHERE value = 1;
SELECT b.value FROM (SELECT toInt8(1) AS id) ANY LEFT JOIN test_00597 AS b USING id WHERE value = 1;
-- Optimize predicate expression with join and nested subquery
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) USING id) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) USING id) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) USING id) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) USING id) WHERE id = 1;
-- Optimize predicate expression with join query and qualified
ANALYZE SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b USING id WHERE b.id = 1;
SELECT * FROM (SELECT * FROM test.test_00597) ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b USING id WHERE b.id = 1;
ANALYZE SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) AS b USING id WHERE b.id = 1;
SELECT * FROM (SELECT * FROM test_00597) ANY LEFT JOIN (SELECT * FROM test_00597) AS b USING id WHERE b.id = 1;
-- Compatibility test
ANALYZE SELECT * FROM (SELECT toInt8(1) AS id, toDate('2000-01-01') AS date FROM system.numbers LIMIT 1) ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b USING date, id WHERE b.date = toDate('2000-01-01');
SELECT * FROM (SELECT toInt8(1) AS id, toDate('2000-01-01') AS date FROM system.numbers LIMIT 1) ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b USING date, id WHERE b.date = toDate('2000-01-01');
ANALYZE SELECT * FROM (SELECT toInt8(1) AS id, toDate('2000-01-01') AS date FROM system.numbers LIMIT 1) ANY LEFT JOIN (SELECT * FROM test_00597) AS b USING date, id WHERE b.date = toDate('2000-01-01');
SELECT * FROM (SELECT toInt8(1) AS id, toDate('2000-01-01') AS date FROM system.numbers LIMIT 1) ANY LEFT JOIN (SELECT * FROM test_00597) AS b USING date, id WHERE b.date = toDate('2000-01-01');
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) AS a ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b ON a.id = b.id) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test.test_00597) AS a ANY LEFT JOIN (SELECT * FROM test.test_00597) AS b ON a.id = b.id) WHERE id = 1;
ANALYZE SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) AS a ANY LEFT JOIN (SELECT * FROM test_00597) AS b ON a.id = b.id) WHERE id = 1;
SELECT * FROM (SELECT * FROM (SELECT * FROM test_00597) AS a ANY LEFT JOIN (SELECT * FROM test_00597) AS b ON a.id = b.id) WHERE id = 1;
DROP TABLE IF EXISTS test.test_00597;
DROP TABLE IF EXISTS test.test_view_00597;
DROP TABLE IF EXISTS test_00597;
DROP TABLE IF EXISTS test_view_00597;
CREATE VIEW test.test_view_00599 (`id` UInt64) AS SELECT * FROM test.test_00599 WHERE id = (SELECT 1)
CREATE VIEW default.test_view_00599 (`id` UInt64) AS SELECT * FROM default.test_00599 WHERE id = (SELECT 1)
DROP TABLE IF EXISTS test.test_00599;
DROP TABLE IF EXISTS test.test_view_00599;
DROP TABLE IF EXISTS test_00599;
DROP TABLE IF EXISTS test_view_00599;
CREATE TABLE test.test_00599(id UInt64) ENGINE = Log;
CREATE VIEW test.test_view_00599 AS SELECT * FROM test.test_00599 WHERE id = (SELECT 1);
CREATE TABLE test_00599(id UInt64) ENGINE = Log;
CREATE VIEW test_view_00599 AS SELECT * FROM test_00599 WHERE id = (SELECT 1);
DETACH TABLE test.test_view_00599;
ATTACH TABLE test.test_view_00599;
DETACH TABLE test_view_00599;
ATTACH TABLE test_view_00599;
SHOW CREATE TABLE test.test_view_00599;
SHOW CREATE TABLE test_view_00599;
DROP TABLE IF EXISTS test.test_00599;
DROP TABLE IF EXISTS test.test_view_00599;
DROP TABLE IF EXISTS test_00599;
DROP TABLE IF EXISTS test_view_00599;
CREATE DATABASE test ENGINE = Ordinary
CREATE DATABASE test_00604 ENGINE = Ordinary
create database if not exists test;
drop table if exists test.tab;
create table test.tab (date Date, time DateTime, data String) ENGINE = MergeTree(date, (time, data), 8192);
insert into test.tab values ('2018-01-21','2018-01-21 15:12:13','test');
select time FROM remote('127.0.0.{1,2}', test.tab) WHERE date = '2018-01-21' limit 2;
drop table test.tab;
drop table if exists tab;
create table tab (date Date, time DateTime, data String) ENGINE = MergeTree(date, (time, data), 8192);
insert into tab values ('2018-01-21','2018-01-21 15:12:13','test');
select time FROM remote('127.0.0.{1,2}', currentDatabase(), tab) WHERE date = '2018-01-21' limit 2;
drop table tab;
DROP TABLE IF EXISTS test.src;
DROP TABLE IF EXISTS test.dst;
DROP TABLE IF EXISTS src;
DROP TABLE IF EXISTS dst;
CREATE TABLE test.src (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
CREATE TABLE test.dst (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
CREATE TABLE src (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
CREATE TABLE dst (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
SELECT 'Initial';
INSERT INTO test.src VALUES (0, '0', 1);
INSERT INTO test.src VALUES (1, '0', 1);
INSERT INTO test.src VALUES (1, '1', 1);
INSERT INTO test.src VALUES (2, '0', 1);
INSERT INTO src VALUES (0, '0', 1);
INSERT INTO src VALUES (1, '0', 1);
INSERT INTO src VALUES (1, '1', 1);
INSERT INTO src VALUES (2, '0', 1);
INSERT INTO test.dst VALUES (0, '1', 2);
INSERT INTO test.dst VALUES (1, '1', 2), (1, '2', 2);
INSERT INTO test.dst VALUES (2, '1', 2);
INSERT INTO dst VALUES (0, '1', 2);
INSERT INTO dst VALUES (1, '1', 2), (1, '2', 2);
INSERT INTO dst VALUES (2, '1', 2);
SELECT count(), sum(d) FROM test.src;
SELECT count(), sum(d) FROM test.dst;
SELECT count(), sum(d) FROM src;
SELECT count(), sum(d) FROM dst;
SELECT 'REPLACE simple';
ALTER TABLE test.dst REPLACE PARTITION 1 FROM test.src;
ALTER TABLE test.src DROP PARTITION 1;
SELECT count(), sum(d) FROM test.src;
SELECT count(), sum(d) FROM test.dst;
ALTER TABLE dst REPLACE PARTITION 1 FROM src;
ALTER TABLE src DROP PARTITION 1;
SELECT count(), sum(d) FROM src;
SELECT count(), sum(d) FROM dst;
SELECT 'REPLACE empty';
ALTER TABLE test.src DROP PARTITION 1;
ALTER TABLE test.dst REPLACE PARTITION 1 FROM test.src;
SELECT count(), sum(d) FROM test.dst;
ALTER TABLE src DROP PARTITION 1;
ALTER TABLE dst REPLACE PARTITION 1 FROM src;
SELECT count(), sum(d) FROM dst;
SELECT 'REPLACE recursive';
ALTER TABLE test.dst DROP PARTITION 1;
INSERT INTO test.dst VALUES (1, '1', 2), (1, '2', 2);
ALTER TABLE dst DROP PARTITION 1;
INSERT INTO dst VALUES (1, '1', 2), (1, '2', 2);
CREATE TEMPORARY table test_block_numbers (m UInt64);
INSERT INTO test_block_numbers SELECT max(max_block_number) AS m FROM system.parts WHERE database='test' AND table='dst' AND active AND name LIKE '1_%';
INSERT INTO test_block_numbers SELECT max(max_block_number) AS m FROM system.parts WHERE database=currentDatabase() AND table='dst' AND active AND name LIKE '1_%';
ALTER TABLE test.dst REPLACE PARTITION 1 FROM test.dst;
SELECT count(), sum(d) FROM test.dst;
ALTER TABLE dst REPLACE PARTITION 1 FROM dst;
SELECT count(), sum(d) FROM dst;
INSERT INTO test_block_numbers SELECT max(max_block_number) AS m FROM system.parts WHERE database='test' AND table='dst' AND active AND name LIKE '1_%';
INSERT INTO test_block_numbers SELECT max(max_block_number) AS m FROM system.parts WHERE database=currentDatabase() AND table='dst' AND active AND name LIKE '1_%';
SELECT (max(m) - min(m) > 1) AS new_block_is_generated FROM test_block_numbers;
DROP TEMPORARY TABLE test_block_numbers;
SELECT 'ATTACH FROM';
ALTER TABLE test.dst DROP PARTITION 1;
DROP TABLE test.src;
ALTER TABLE dst DROP PARTITION 1;
DROP TABLE src;
CREATE TABLE test.src (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
INSERT INTO test.src VALUES (1, '0', 1);
INSERT INTO test.src VALUES (1, '1', 1);
CREATE TABLE src (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k;
INSERT INTO src VALUES (1, '0', 1);
INSERT INTO src VALUES (1, '1', 1);
SYSTEM STOP MERGES test.dst;
INSERT INTO test.dst VALUES (1, '1', 2);
ALTER TABLE test.dst ATTACH PARTITION 1 FROM test.src;
SELECT count(), sum(d) FROM test.dst;
SYSTEM STOP MERGES dst;
INSERT INTO dst VALUES (1, '1', 2);
ALTER TABLE dst ATTACH PARTITION 1 FROM src;
SELECT count(), sum(d) FROM dst;
SELECT 'OPTIMIZE';
SELECT count(), sum(d), uniqExact(_part) FROM test.dst;
SELECT count(), sum(d), uniqExact(_part) FROM dst;
SYSTEM START MERGES;
SET optimize_throw_if_noop=1;
OPTIMIZE TABLE test.dst;
SELECT count(), sum(d), uniqExact(_part) FROM test.dst;
OPTIMIZE TABLE dst;
SELECT count(), sum(d), uniqExact(_part) FROM dst;
SELECT 'After restart';
DETACH TABLE test.dst;
ATTACH TABLE test.dst;
SELECT count(), sum(d) FROM test.dst;
DETACH TABLE dst;
ATTACH TABLE dst;
SELECT count(), sum(d) FROM dst;
SELECT 'DETACH+ATTACH PARTITION';
ALTER TABLE test.dst DETACH PARTITION 0;
ALTER TABLE test.dst DETACH PARTITION 1;
ALTER TABLE test.dst DETACH PARTITION 2;
ALTER TABLE test.dst ATTACH PARTITION 1;
SELECT count(), sum(d) FROM test.dst;
DROP TABLE IF EXISTS test.src;
DROP TABLE IF EXISTS test.dst;
ALTER TABLE dst DETACH PARTITION 0;
ALTER TABLE dst DETACH PARTITION 1;
ALTER TABLE dst DETACH PARTITION 2;
ALTER TABLE dst ATTACH PARTITION 1;
SELECT count(), sum(d) FROM dst;
DROP TABLE IF EXISTS src;
DROP TABLE IF EXISTS dst;
CREATE DATABASE IF NOT EXISTS test;
DROP TABLE IF EXISTS test.check_query_comment_column;
DROP TABLE IF EXISTS check_query_comment_column;
-- Check COMMENT COLUMN and MODIFY COLUMN statements with simple engine
CREATE TABLE test.check_query_comment_column
CREATE TABLE check_query_comment_column
(
first_column UInt8 DEFAULT 1 COMMENT 'comment 1',
second_column UInt8 MATERIALIZED first_column COMMENT 'comment 2',
......@@ -11,24 +10,24 @@ CREATE TABLE test.check_query_comment_column
fifth_column UInt8
) ENGINE = TinyLog;
SHOW CREATE TABLE test.check_query_comment_column;
DESCRIBE TABLE test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
DESCRIBE TABLE check_query_comment_column;
SELECT table, name, comment
FROM system.columns
WHERE table = 'check_query_comment_column' AND database = 'test'
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
ALTER TABLE test.check_query_comment_column
ALTER TABLE check_query_comment_column
COMMENT COLUMN first_column 'comment 1_1',
COMMENT COLUMN second_column 'comment 2_1',
COMMENT COLUMN third_column 'comment 3_1',
COMMENT COLUMN fourth_column 'comment 4_1',
COMMENT COLUMN fifth_column 'comment 5_1';
SHOW CREATE TABLE test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
ALTER TABLE test.check_query_comment_column
ALTER TABLE check_query_comment_column
MODIFY COLUMN first_column COMMENT 'comment 1_2',
MODIFY COLUMN second_column COMMENT 'comment 2_2',
MODIFY COLUMN third_column COMMENT 'comment 3_2',
......@@ -37,14 +36,14 @@ ALTER TABLE test.check_query_comment_column
SELECT table, name, comment
FROM system.columns
WHERE table = 'check_query_comment_column' AND database = 'test'
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
SHOW CREATE TABLE test.check_query_comment_column;
DROP TABLE IF EXISTS test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
DROP TABLE IF EXISTS check_query_comment_column;
-- Check `ALTER TABLE table_name COMMENT COLUMN 'comment'` statement with MergeTree engine
CREATE TABLE test.check_query_comment_column
CREATE TABLE check_query_comment_column
(
first_column UInt8 COMMENT 'comment 1',
second_column UInt8 COMMENT 'comment 2',
......@@ -54,38 +53,38 @@ CREATE TABLE test.check_query_comment_column
PARTITION BY second_column
SAMPLE BY first_column;
SHOW CREATE TABLE test.check_query_comment_column;
DESCRIBE TABLE test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
DESCRIBE TABLE check_query_comment_column;
SELECT table, name, comment
FROM system.columns
WHERE table = 'check_query_comment_column' AND database = 'test'
WHERE table = 'check_query_comment_column' AND database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
ALTER TABLE test.check_query_comment_column
ALTER TABLE check_query_comment_column
COMMENT COLUMN first_column 'comment 1_2',
COMMENT COLUMN second_column 'comment 2_2',
COMMENT COLUMN third_column 'comment 3_2';
SHOW CREATE TABLE test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
ALTER TABLE test.check_query_comment_column
ALTER TABLE check_query_comment_column
MODIFY COLUMN first_column COMMENT 'comment 1_3',
MODIFY COLUMN second_column COMMENT 'comment 2_3',
MODIFY COLUMN third_column COMMENT 'comment 3_3';
SHOW CREATE TABLE test.check_query_comment_column;
SHOW CREATE TABLE check_query_comment_column;
ALTER TABLE test.check_query_comment_column
ALTER TABLE check_query_comment_column
MODIFY COLUMN first_column DEFAULT 1 COMMENT 'comment 1_3',
MODIFY COLUMN second_column COMMENT 'comment 2_3', -- We can't change default value of partition key.
MODIFY COLUMN third_column DEFAULT 1 COMMENT 'comment 3_3';
SELECT table, name, comment
FROM system.columns
WHERE table = 'check_query_comment_column' and database = 'test'
WHERE table = 'check_query_comment_column' and database = currentDatabase()
FORMAT PrettyCompactNoEscapes;
DROP TABLE IF EXISTS test.check_query_comment_column;
DROP TABLE IF EXISTS check_query_comment_column;
-- TODO: add here tests with ReplicatedMergeTree
CREATE DATABASE IF NOT EXISTS test; -- foo
CREATE DATABASE IF NOT EXISTS test_00741; -- foo
DROP DATABASE test_00741;
......@@ -29,3 +29,6 @@ from (
where dt = '2019-01-14' and id = 1
)
group by dt, id;
DROP TABLE table1;
DROP TABLE table2;
......@@ -116,3 +116,6 @@ TRUNCATE TABLE compression_codec_multiple_tiny_log;
INSERT INTO compression_codec_multiple_tiny_log select modulo(number, 100), toString(number), toDate('2018-12-01'), 5.5 * number FROM system.numbers limit 10000;
SELECT sum(cityHash64(*)) FROM compression_codec_multiple_tiny_log;
DROP TABLE compression_codec_log;
DROP TABLE compression_codec_tiny_log;
SET send_logs_level = 'none';
DROP TABLE IF EXISTS test.delta_codec_synthetic;
DROP TABLE IF EXISTS test.default_codec_synthetic;
DROP TABLE IF EXISTS delta_codec_synthetic;
DROP TABLE IF EXISTS default_codec_synthetic;
CREATE TABLE test.delta_codec_synthetic
CREATE TABLE delta_codec_synthetic
(
id UInt64 Codec(Delta, ZSTD)
) ENGINE MergeTree() ORDER BY tuple();
CREATE TABLE test.default_codec_synthetic
CREATE TABLE default_codec_synthetic
(
id UInt64 Codec(ZSTD)
) ENGINE MergeTree() ORDER BY tuple();
INSERT INTO test.delta_codec_synthetic SELECT number FROM system.numbers LIMIT 5000000;
INSERT INTO test.default_codec_synthetic SELECT number FROM system.numbers LIMIT 5000000;
INSERT INTO delta_codec_synthetic SELECT number FROM system.numbers LIMIT 5000000;
INSERT INTO default_codec_synthetic SELECT number FROM system.numbers LIMIT 5000000;
OPTIMIZE TABLE test.delta_codec_synthetic FINAL;
OPTIMIZE TABLE test.default_codec_synthetic FINAL;
OPTIMIZE TABLE delta_codec_synthetic FINAL;
OPTIMIZE TABLE default_codec_synthetic FINAL;
SELECT
floor(big_size / small_size) AS ratio
FROM
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database == 'test' and table == 'delta_codec_synthetic')
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database == currentDatabase() and table == 'delta_codec_synthetic')
INNER JOIN
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database == 'test' and table == 'default_codec_synthetic')
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database == currentDatabase() and table == 'default_codec_synthetic')
USING(key);
SELECT
small_hash == big_hash
FROM
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM test.delta_codec_synthetic)
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM delta_codec_synthetic)
INNER JOIN
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM test.default_codec_synthetic)
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM default_codec_synthetic)
USING(key);
DROP TABLE IF EXISTS test.delta_codec_synthetic;
DROP TABLE IF EXISTS test.default_codec_synthetic;
DROP TABLE IF EXISTS delta_codec_synthetic;
DROP TABLE IF EXISTS default_codec_synthetic;
DROP TABLE IF EXISTS test.delta_codec_float;
DROP TABLE IF EXISTS test.default_codec_float;
DROP TABLE IF EXISTS delta_codec_float;
DROP TABLE IF EXISTS default_codec_float;
CREATE TABLE test.delta_codec_float
CREATE TABLE delta_codec_float
(
id Float64 Codec(Delta, LZ4HC)
) ENGINE MergeTree() ORDER BY tuple();
CREATE TABLE test.default_codec_float
CREATE TABLE default_codec_float
(
id Float64 Codec(LZ4HC)
) ENGINE MergeTree() ORDER BY tuple();
INSERT INTO test.delta_codec_float SELECT number FROM numbers(1547510400, 500000) WHERE number % 3 == 0 OR number % 5 == 0 OR number % 7 == 0 OR number % 11 == 0;
INSERT INTO test.default_codec_float SELECT * from test.delta_codec_float;
INSERT INTO delta_codec_float SELECT number FROM numbers(1547510400, 500000) WHERE number % 3 == 0 OR number % 5 == 0 OR number % 7 == 0 OR number % 11 == 0;
INSERT INTO default_codec_float SELECT * from delta_codec_float;
OPTIMIZE TABLE test.delta_codec_float FINAL;
OPTIMIZE TABLE test.default_codec_float FINAL;
OPTIMIZE TABLE delta_codec_float FINAL;
OPTIMIZE TABLE default_codec_float FINAL;
SELECT
floor(big_size / small_size) as ratio
FROM
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database = 'test' and table = 'delta_codec_float')
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database = currentDatabase() and table = 'delta_codec_float')
INNER JOIN
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database = 'test' and table = 'default_codec_float') USING(key);
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database = currentDatabase() and table = 'default_codec_float') USING(key);
SELECT
small_hash == big_hash
FROM
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM test.delta_codec_float)
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM delta_codec_float)
INNER JOIN
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM test.default_codec_float)
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM default_codec_float)
USING(key);
DROP TABLE IF EXISTS test.delta_codec_float;
DROP TABLE IF EXISTS test.default_codec_float;
DROP TABLE IF EXISTS delta_codec_float;
DROP TABLE IF EXISTS default_codec_float;
DROP TABLE IF EXISTS test.delta_codec_string;
DROP TABLE IF EXISTS test.default_codec_string;
DROP TABLE IF EXISTS delta_codec_string;
DROP TABLE IF EXISTS default_codec_string;
CREATE TABLE test.delta_codec_string
CREATE TABLE delta_codec_string
(
id Float64 Codec(Delta, LZ4)
) ENGINE MergeTree() ORDER BY tuple();
CREATE TABLE test.default_codec_string
CREATE TABLE default_codec_string
(
id Float64 Codec(LZ4)
) ENGINE MergeTree() ORDER BY tuple();
INSERT INTO test.delta_codec_string SELECT concat(toString(number), toString(number % 100)) FROM numbers(1547510400, 500000);
INSERT INTO test.default_codec_string SELECT * from test.delta_codec_string;
INSERT INTO delta_codec_string SELECT concat(toString(number), toString(number % 100)) FROM numbers(1547510400, 500000);
INSERT INTO default_codec_string SELECT * from delta_codec_string;
OPTIMIZE TABLE test.delta_codec_string FINAL;
OPTIMIZE TABLE test.default_codec_string FINAL;
OPTIMIZE TABLE delta_codec_string FINAL;
OPTIMIZE TABLE default_codec_string FINAL;
SELECT
floor(big_size / small_size) as ratio
FROM
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database = 'test' and table = 'delta_codec_string')
(SELECT 1 AS key, sum(bytes_on_disk) AS small_size FROM system.parts WHERE database = currentDatabase() and table = 'delta_codec_string')
INNER JOIN
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database = 'test' and table = 'default_codec_string') USING(key);
(SELECT 1 AS key, sum(bytes_on_disk) as big_size FROM system.parts WHERE database = currentDatabase() and table = 'default_codec_string') USING(key);
SELECT
small_hash == big_hash
FROM
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM test.delta_codec_string)
(SELECT 1 AS key, sum(cityHash64(*)) AS small_hash FROM delta_codec_string)
INNER JOIN
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM test.default_codec_string)
(SELECT 1 AS key, sum(cityHash64(*)) AS big_hash FROM default_codec_string)
USING(key);
DROP TABLE IF EXISTS test.delta_codec_string;
DROP TABLE IF EXISTS test.default_codec_string;
DROP TABLE IF EXISTS delta_codec_string;
DROP TABLE IF EXISTS default_codec_string;
......@@ -9,3 +9,5 @@ ALTER TABLE alter_update_00806 UPDATE e = CAST('foo', 'Enum8(\'foo\' = 1, \'bar\
SELECT sleep(1); -- TODO: there should be setting for sync ALTER UPDATE someday.
SELECT e FROM alter_update_00806 ORDER BY d;
DROP TABLE alter_update_00806;
CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10, INDEX idx3 u64 - i32 TYPE minmax GRANULARITY 10, INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE default.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10, INDEX idx3 u64 - i32 TYPE minmax GRANULARITY 10, INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
1 2
1 2
1 2
......@@ -6,15 +6,15 @@ CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 T
1 2
1 2
1 2
CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx3 u64 - i32 TYPE minmax GRANULARITY 10, INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE default.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx3 u64 - i32 TYPE minmax GRANULARITY 10, INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
1 2
1 2
1 2
1 2
1 2
1 2
CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE default.minmax_idx (`u64` UInt64, `i32` Int32) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE default.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
1 2
1 2
1 2
......@@ -23,6 +23,6 @@ CREATE TABLE test.minmax_idx (`u64` UInt64, `i32` Int32, INDEX idx1 u64 * i32 T
1 2
1 2
1 2
CREATE TABLE test.minmax_idx2 (`u64` UInt64, `i32` Int32) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
CREATE TABLE default.minmax_idx2 (`u64` UInt64, `i32` Int32) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192
1 2
1 2
DROP TABLE IF EXISTS test.minmax_idx;
DROP TABLE IF EXISTS test.minmax_idx2;
DROP TABLE IF EXISTS minmax_idx;
DROP TABLE IF EXISTS minmax_idx2;
SET allow_experimental_data_skipping_indices = 1;
CREATE TABLE test.minmax_idx
CREATE TABLE minmax_idx
(
u64 UInt64,
i32 Int32
) ENGINE = MergeTree()
ORDER BY u64;
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
ALTER TABLE test.minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx ADD INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx ADD INDEX idx3 (u64 - i32) TYPE minmax GRANULARITY 10 AFTER idx1;
ALTER TABLE minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
ALTER TABLE minmax_idx ADD INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10;
ALTER TABLE minmax_idx ADD INDEX idx3 (u64 - i32) TYPE minmax GRANULARITY 10 AFTER idx1;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx DROP INDEX idx1;
ALTER TABLE minmax_idx DROP INDEX idx1;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx DROP INDEX idx2;
ALTER TABLE test.minmax_idx DROP INDEX idx3;
ALTER TABLE minmax_idx DROP INDEX idx2;
ALTER TABLE minmax_idx DROP INDEX idx3;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE minmax_idx;
ALTER TABLE test.minmax_idx ADD INDEX idx1 (u64 * i32) TYPE minmax GRANULARITY 10;
ALTER TABLE minmax_idx ADD INDEX idx1 (u64 * i32) TYPE minmax GRANULARITY 10;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
CREATE TABLE test.minmax_idx2
CREATE TABLE minmax_idx2
(
u64 UInt64,
i32 Int32,
......@@ -55,16 +55,16 @@ CREATE TABLE test.minmax_idx2
) ENGINE = MergeTree()
ORDER BY u64;
INSERT INTO test.minmax_idx2 VALUES (1, 2);
INSERT INTO test.minmax_idx2 VALUES (1, 2);
INSERT INTO minmax_idx2 VALUES (1, 2);
INSERT INTO minmax_idx2 VALUES (1, 2);
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx2 WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
ALTER TABLE minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
SHOW CREATE TABLE test.minmax_idx2;
SHOW CREATE TABLE minmax_idx2;
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
SELECT * FROM minmax_idx2 WHERE u64 * i32 = 2;
DROP TABLE test.minmax_idx;
DROP TABLE test.minmax_idx2;
\ No newline at end of file
DROP TABLE minmax_idx;
DROP TABLE minmax_idx2;
......@@ -65,3 +65,4 @@ SELECT t3_00848.id = 'l', t3_00848.not_id = 'l' FROM t1_00848 LEFT JOIN t3_00848
DROP TABLE t1_00848;
DROP TABLE t2_00848;
DROP TABLE t3_00848;
......@@ -42,3 +42,5 @@ CREATE TABLE IF NOT EXISTS defaults
) ENGINE = Memory;
insert into defaults values (toDateTime('2016-06-15 23:00:00')), (toDateTime('2016-06-15 23:00:00')), (toDateTime('2016-06-15 23:00:00')), (toDateTime('2016-06-15 23:00:00')), (toDateTime('2016-06-15 24:00:00')), (toDateTime('2016-06-15 24:00:00')), (toDateTime('2016-06-15 24:00:00')), (toDateTime('2017-06-15 24:00:00')), (toDateTime('2017-06-15 24:00:00')), (toDateTime('2018-06-15 24:00:00')), (toDateTime('2018-06-15 24:00:00')), (toDateTime('2019-06-15 24:00:00'));
select val < 2.189 and val > 2.1886 from (select entropy(vals) as val from defaults);
DROP TABLE defaults;
-- basic test
drop table if exists test.simple;
drop table if exists simple;
create table test.simple (id UInt64,val SimpleAggregateFunction(sum,Double)) engine=AggregatingMergeTree order by id;
insert into test.simple select number,number from system.numbers limit 10;
create table simple (id UInt64,val SimpleAggregateFunction(sum,Double)) engine=AggregatingMergeTree order by id;
insert into simple select number,number from system.numbers limit 10;
select * from test.simple;
select * from test.simple final;
select toTypeName(val) from test.simple limit 1;
select * from simple;
select * from simple final;
select toTypeName(val) from simple limit 1;
-- merge
insert into test.simple select number,number from system.numbers limit 10;
insert into simple select number,number from system.numbers limit 10;
select * from test.simple final;
select * from simple final;
optimize table test.simple final;
select * from test.simple;
optimize table simple final;
select * from simple;
-- complex types
drop table if exists test.simple;
drop table if exists simple;
create table test.simple (id UInt64,nullable_str SimpleAggregateFunction(anyLast,Nullable(String)),low_str SimpleAggregateFunction(anyLast,LowCardinality(Nullable(String))),ip SimpleAggregateFunction(anyLast,IPv4)) engine=AggregatingMergeTree order by id;
insert into test.simple values(1,'1','1','1.1.1.1');
insert into test.simple values(1,null,'2','2.2.2.2');
create table simple (id UInt64,nullable_str SimpleAggregateFunction(anyLast,Nullable(String)),low_str SimpleAggregateFunction(anyLast,LowCardinality(Nullable(String))),ip SimpleAggregateFunction(anyLast,IPv4)) engine=AggregatingMergeTree order by id;
insert into simple values(1,'1','1','1.1.1.1');
insert into simple values(1,null,'2','2.2.2.2');
-- String longer then MAX_SMALL_STRING_SIZE (actual string length is 100)
insert into test.simple values(10,'10','10','10.10.10.10');
insert into test.simple values(10,'2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222','20','20.20.20.20');
insert into simple values(10,'10','10','10.10.10.10');
insert into simple values(10,'2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222','20','20.20.20.20');
select * from test.simple final;
select toTypeName(nullable_str),toTypeName(low_str),toTypeName(ip) from test.simple limit 1;
select * from simple final;
select toTypeName(nullable_str),toTypeName(low_str),toTypeName(ip) from simple limit 1;
CREATE TABLE test.ttl (`d` Date, `a` Int32) ENGINE = MergeTree PARTITION BY toDayOfMonth(d) ORDER BY a TTL d + toIntervalDay(1) SETTINGS index_granularity = 8192
CREATE TABLE default.ttl (`d` Date, `a` Int32) ENGINE = MergeTree PARTITION BY toDayOfMonth(d) ORDER BY a TTL d + toIntervalDay(1) SETTINGS index_granularity = 8192
2100-10-10 3
2100-10-10 4
d Date
......
USE test;
DROP TABLE IF EXISTS ipv4_range;
CREATE TABLE ipv4_range(ip IPv4, cidr UInt8) ENGINE = Memory;
......@@ -22,4 +20,3 @@ SELEcT IPv4CIDRToRange(toIPv4('255.255.255.255'), 8);
SELECT IPv4CIDRToRange(toIPv4('192.168.5.2'), 32);
SELECT IPv4CIDRToRange(toIPv4('0.0.0.0'), 8);
SELECT IPv4CIDRToRange(toIPv4('255.0.0.0'), 4);
......@@ -16,4 +16,4 @@ select ans > -67.0 and ans < -66.9 from
(with (select state + state + state from model) as model select evalMLMethod(model, predict1, predict2) as ans from defaults limit 1);
DROP TABLE defaults;
DROP TABLE models;
DROP TABLE model;
drop table if exists test.limit_by;
drop table if exists limit_by;
create table test.limit_by(id Int, val Int) engine = Memory;
create table limit_by(id Int, val Int) engine = Memory;
insert into test.limit_by values(1, 100), (1, 110), (1, 120), (1, 130), (2, 200), (2, 210), (2, 220), (3, 300);
insert into limit_by values(1, 100), (1, 110), (1, 120), (1, 130), (2, 200), (2, 210), (2, 220), (3, 300);
select * from test.limit_by order by id, val limit 2, 2 by id;
select * from test.limit_by order by id, val limit 2 offset 1 by id;
select * from test.limit_by order by id, val limit 1, 2 by id limit 3;
select * from test.limit_by order by id, val limit 1, 2 by id limit 3 offset 1;
select * from limit_by order by id, val limit 2, 2 by id;
select * from limit_by order by id, val limit 2 offset 1 by id;
select * from limit_by order by id, val limit 1, 2 by id limit 3;
select * from limit_by order by id, val limit 1, 2 by id limit 3 offset 1;
DROP TABLE IF EXISTS test.nullt;
DROP TABLE IF EXISTS nullt;
CREATE TABLE test.nullt (c1 Nullable(UInt32), c2 Nullable(String))ENGINE = Log;
INSERT INTO test.nullt VALUES (1, 'abc'), (2, NULL), (NULL, NULL);
CREATE TABLE nullt (c1 Nullable(UInt32), c2 Nullable(String))ENGINE = Log;
INSERT INTO nullt VALUES (1, 'abc'), (2, NULL), (NULL, NULL);
SELECT c2 = ('abc') FROM test.nullt;
SELECT c2 IN ('abc') FROM test.nullt;
SELECT c2 = ('abc') FROM nullt;
SELECT c2 IN ('abc') FROM nullt;
SELECT c2 IN ('abc', NULL) FROM test.nullt;
SELECT c2 IN ('abc', NULL) FROM nullt;
DROP TABLE IF EXISTS test.nullt;
DROP TABLE IF EXISTS nullt;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册