mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fixed MT alter
This commit is contained in:
parent
9f1a093e0c
commit
506f2c41c8
@ -533,8 +533,13 @@ void DatabaseOrdinary::alterTable(
|
||||
|
||||
ASTPtr new_columns = InterpreterCreateQuery::formatColumns(columns);
|
||||
ASTPtr new_indices = InterpreterCreateQuery::formatIndices(indices);
|
||||
|
||||
ast_create_query.columns_list->replace(ast_create_query.columns_list->columns, new_columns);
|
||||
ast_create_query.columns_list->replace(ast_create_query.columns_list->columns, new_indices);
|
||||
|
||||
if (ast_create_query.columns_list->indices)
|
||||
ast_create_query.columns_list->replace(ast_create_query.columns_list->indices, new_indices);
|
||||
else
|
||||
ast_create_query.columns_list->set(ast_create_query.columns_list->indices, new_indices);
|
||||
|
||||
if (storage_modifier)
|
||||
storage_modifier(*ast_create_query.storage);
|
||||
|
@ -405,9 +405,6 @@ ASTPtr InterpreterCreateQuery::formatColumns(const ColumnsDescription & columns)
|
||||
|
||||
ASTPtr InterpreterCreateQuery::formatIndices(const IndicesDescription & indices)
|
||||
{
|
||||
if (indices.indices.empty())
|
||||
return nullptr;
|
||||
|
||||
auto res = std::make_shared<ASTExpressionList>();
|
||||
|
||||
for (const auto & index : indices.indices)
|
||||
|
@ -1,4 +1,4 @@
|
||||
CREATE TABLE test.minmax_idx ( u64 UInt64, i32 Int32) ENGINE = MergeTree() ORDER BY u64 INDICES idx1 BY u64 * i32 TYPE minmax GRANULARITY 10, idx3 BY u64 - i32 TYPE minmax GRANULARITY 10, idx2 BY u64 + i32 TYPE minmax GRANULARITY 10 SETTINGS index_granularity = 8192
|
||||
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
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
@ -6,7 +6,7 @@ CREATE TABLE test.minmax_idx ( u64 UInt64, i32 Int32) ENGINE = MergeTree() ORDE
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
CREATE TABLE test.minmax_idx ( u64 UInt64, i32 Int32) ENGINE = MergeTree() ORDER BY u64 INDICES idx3 BY u64 - i32 TYPE minmax GRANULARITY 10, idx2 BY u64 + i32 TYPE minmax GRANULARITY 10 SETTINGS index_granularity = 8192
|
||||
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
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
@ -14,7 +14,7 @@ CREATE TABLE test.minmax_idx ( u64 UInt64, i32 Int32) ENGINE = MergeTree() ORDE
|
||||
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) ENGINE = MergeTree() ORDER BY u64 INDICES idx1 BY u64 * i32 TYPE minmax GRANULARITY 10 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
|
||||
1 2
|
||||
1 2
|
||||
1 2
|
||||
|
@ -10,9 +10,9 @@ 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;
|
||||
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;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
@ -37,7 +37,7 @@ ALTER TABLE test.minmax_idx DROP INDEX idx3;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx1 BY u64 * i32 TYPE minmax GRANULARITY 10;
|
||||
ALTER TABLE test.minmax_idx ADD INDEX idx1 (u64 * i32) TYPE minmax GRANULARITY 10;
|
||||
|
||||
SHOW CREATE TABLE test.minmax_idx;
|
||||
|
||||
@ -47,11 +47,11 @@ SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
|
||||
CREATE TABLE test.minmax_idx2
|
||||
(
|
||||
u64 UInt64,
|
||||
i32 Int32
|
||||
i32 Int32,
|
||||
INDEX idx1 (u64 + i32) TYPE minmax GRANULARITY 10,
|
||||
INDEX idx2 u64 * i32 TYPE minmax GRANULARITY 10
|
||||
) ENGINE = MergeTree()
|
||||
ORDER BY u64
|
||||
INDICES idx1 BY u64 + i32 TYPE minmax GRANULARITY 10,
|
||||
idx2 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);
|
||||
|
Loading…
Reference in New Issue
Block a user