ClickHouse/tests/queries/0_stateless/00836_indices_alter_replicated_zookeeper.sql

114 lines
3.5 KiB
MySQL
Raw Normal View History

2019-01-17 09:16:39 +00:00
DROP TABLE IF EXISTS test.minmax_idx;
DROP TABLE IF EXISTS test.minmax_idx_r;
DROP TABLE IF EXISTS test.minmax_idx2;
DROP TABLE IF EXISTS test.minmax_idx2_r;
2020-02-18 09:02:40 +00:00
SET replication_alter_partitions_sync = 2;
2019-02-12 17:54:52 +00:00
2019-01-17 09:16:39 +00:00
CREATE TABLE test.minmax_idx
(
u64 UInt64,
i32 Int32
2020-08-26 17:45:20 +00:00
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00836/indices_alter1', 'r1')
2019-01-17 09:16:39 +00:00
ORDER BY u64;
CREATE TABLE test.minmax_idx_r
(
u64 UInt64,
i32 Int32
2020-08-26 17:45:20 +00:00
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00836/indices_alter1', 'r2')
2019-01-17 09:16:39 +00:00
ORDER BY u64;
INSERT INTO test.minmax_idx VALUES (1, 2);
SYSTEM SYNC REPLICA test.minmax_idx_r;
ALTER TABLE test.minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx_r 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;
2019-01-17 09:16:39 +00:00
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE test.minmax_idx_r;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx_r WHERE u64 * i32 = 2 ORDER BY (u64, i32);
INSERT INTO test.minmax_idx VALUES (1, 4);
INSERT INTO test.minmax_idx_r VALUES (3, 2);
INSERT INTO test.minmax_idx VALUES (1, 5);
INSERT INTO test.minmax_idx_r VALUES (65, 75);
INSERT INTO test.minmax_idx VALUES (19, 9);
SYSTEM SYNC REPLICA test.minmax_idx;
SYSTEM SYNC REPLICA test.minmax_idx_r;
SELECT * FROM test.minmax_idx WHERE u64 * i32 > 1 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx_r WHERE u64 * i32 > 1 ORDER BY (u64, i32);
ALTER TABLE test.minmax_idx DROP INDEX idx1;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE test.minmax_idx_r;
SELECT * FROM test.minmax_idx WHERE u64 * i32 > 1 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx_r WHERE u64 * i32 > 1 ORDER BY (u64, i32);
ALTER TABLE test.minmax_idx DROP INDEX idx2;
ALTER TABLE test.minmax_idx_r DROP INDEX idx3;
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE test.minmax_idx_r;
ALTER TABLE test.minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
2019-01-17 09:16:39 +00:00
SHOW CREATE TABLE test.minmax_idx;
SHOW CREATE TABLE test.minmax_idx_r;
SELECT * FROM test.minmax_idx WHERE u64 * i32 > 1 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx_r WHERE u64 * i32 > 1 ORDER BY (u64, i32);
CREATE TABLE test.minmax_idx2
(
u64 UInt64,
i32 Int32,
INDEX idx1 u64 + i32 TYPE minmax GRANULARITY 10,
INDEX idx2 u64 * i32 TYPE minmax GRANULARITY 10
2020-08-26 17:45:20 +00:00
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00836/indices_alter2', 'r1')
ORDER BY u64;
2019-01-17 09:16:39 +00:00
CREATE TABLE test.minmax_idx2_r
(
u64 UInt64,
i32 Int32,
INDEX idx1 u64 + i32 TYPE minmax GRANULARITY 10,
INDEX idx2 u64 * i32 TYPE minmax GRANULARITY 10
2020-08-26 17:45:20 +00:00
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test_00836/indices_alter2', 'r2')
ORDER BY u64;
2019-01-17 09:16:39 +00:00
SHOW CREATE TABLE test.minmax_idx2;
SHOW CREATE TABLE test.minmax_idx2_r;
INSERT INTO test.minmax_idx2 VALUES (1, 2);
INSERT INTO test.minmax_idx2_r VALUES (1, 3);
SYSTEM SYNC REPLICA test.minmax_idx2;
SYSTEM SYNC REPLICA test.minmax_idx2_r;
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 >= 2 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx2_r WHERE u64 * i32 >= 2 ORDER BY (u64, i32);
2020-02-18 09:02:40 +00:00
ALTER TABLE test.minmax_idx2_r DROP INDEX idx1, DROP INDEX idx2;
2019-01-17 09:16:39 +00:00
SHOW CREATE TABLE test.minmax_idx2;
SHOW CREATE TABLE test.minmax_idx2_r;
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 >= 2 ORDER BY (u64, i32);
SELECT * FROM test.minmax_idx2_r WHERE u64 * i32 >= 2 ORDER BY (u64, i32);
DROP TABLE test.minmax_idx;
DROP TABLE test.minmax_idx_r;
DROP TABLE test.minmax_idx2;
2020-02-17 09:12:01 +00:00
DROP TABLE test.minmax_idx2_r;