mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
alter fix + test
This commit is contained in:
parent
2de2b6f32e
commit
b4ce03ea7e
@ -321,7 +321,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description, ASTPtr & orde
|
||||
if (indexes_decl_ast)
|
||||
new_indexes_decl_ast = indexes_decl_ast->clone();
|
||||
else
|
||||
new_indexes_decl_ast = ASTExpressionList().ptr();
|
||||
new_indexes_decl_ast = std::make_shared<ASTExpressionList>();
|
||||
|
||||
if (std::any_of(
|
||||
new_indexes_decl_ast->children.cbegin(),
|
||||
@ -363,7 +363,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description, ASTPtr & orde
|
||||
if (indexes_decl_ast)
|
||||
new_indexes_decl_ast = indexes_decl_ast->clone();
|
||||
else
|
||||
new_indexes_decl_ast = ASTExpressionList().ptr();
|
||||
new_indexes_decl_ast = std::make_shared<ASTExpressionList>();
|
||||
|
||||
auto erase_it = std::find_if(
|
||||
new_indexes_decl_ast->children.begin(),
|
||||
|
68
dbms/tests/queries/0_stateless/00824_indices_alter.sql
Normal file
68
dbms/tests/queries/0_stateless/00824_indices_alter.sql
Normal file
@ -0,0 +1,68 @@
|
||||
DROP TABLE IF EXISTS test.minmax_idx;
|
||||
DROP TABLE IF EXISTS test.minmax_idx2;
|
||||
|
||||
CREATE TABLE test.minmax_idx
|
||||
(
|
||||
u64 UInt64,
|
||||
i32 Int32
|
||||
) ENGINE = MergeTree()
|
||||
ORDER BY u64;
|
||||
|
||||
INSERT INTO test.minmax_idx VALUES (1, 2);
|
||||
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx1 BY u64 * i32 TYPE minmax GRANULARITY 10;
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx2 BY u64 * i32 TYPE minmax GRANULARITY 10;
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx3 BY u64 * i32 TYPE minmax GRANULARITY 10 AFTER idx1;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 3;
|
||||
|
||||
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);
|
||||
|
||||
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 3;
|
||||
|
||||
ALTER TABLE test.minmax_idx DROP INDEX idx1
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 3;
|
||||
|
||||
ALTER TABLE test.minmax_idx DROP INDEX idx3;
|
||||
ALTER TABLE test.minmax_idx DROP INDEX idx2;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx1 BY u64 * i32 TYPE minmax GRANULARITY 10;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 3;
|
||||
|
||||
|
||||
CREATE TABLE test.minmax_idx2
|
||||
(
|
||||
u64 UInt64,
|
||||
i32 Int32
|
||||
) ENGINE = MergeTree()
|
||||
idx2 BY u64 * i32 TYPE minmax GRANULARITY 10
|
||||
INDEXES idx1 BY u64 * i32 TYPE minmax GRANULARITY 10,
|
||||
ORDER BY u64;
|
||||
|
||||
INSERT INTO test.minmax_idx2 VALUES (1, 2);
|
||||
INSERT INTO test.minmax_idx2 VALUES (1, 2);
|
||||
|
||||
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 3;
|
||||
|
||||
ALTER TABLE test.minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx2;
|
||||
|
||||
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 3;
|
||||
|
||||
DROP TABLE test.minmax_idx;
|
||||
DROP TABLE test.minmax_idx2;
|
Loading…
Reference in New Issue
Block a user