mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-18 04:12:19 +00:00
Fix constraints
This commit is contained in:
parent
a5a9048109
commit
0d375e4522
@ -327,7 +327,8 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata, const Context & con
|
||||
}
|
||||
else if (type == COMMENT_COLUMN)
|
||||
{
|
||||
metadata.columns.modify(column_name, [&](ColumnDescription & column) { column.comment = *comment; });
|
||||
metadata.columns.modify(column_name,
|
||||
[&](ColumnDescription & column) { column.comment = *comment; });
|
||||
}
|
||||
else if (type == ADD_INDEX)
|
||||
{
|
||||
|
@ -404,10 +404,10 @@ void MergeTreeData::setProperties(const StorageInMemoryMetadata & metadata, bool
|
||||
{
|
||||
/// Other parts of metadata initialized is separate methods
|
||||
setColumns(std::move(metadata.columns));
|
||||
setSecondaryIndices(metadata.secondary_indices);
|
||||
setConstraints(metadata.constraints);
|
||||
setSortingKey(new_sorting_key);
|
||||
setPrimaryKey(new_primary_key);
|
||||
setSecondaryIndices(std::move(metadata.secondary_indices));
|
||||
setConstraints(std::move(metadata.constraints));
|
||||
setSortingKey(std::move(new_sorting_key));
|
||||
setPrimaryKey(std::move(new_primary_key));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,6 +506,11 @@ static StoragePtr create(const StorageFactory::Arguments & args)
|
||||
|
||||
if (args.storage_def->primary_key)
|
||||
metadata.primary_key = KeyDescription::getKeyFromAST(args.storage_def->primary_key->ptr(), metadata.columns, args.context);
|
||||
else
|
||||
{
|
||||
metadata.primary_key = metadata.sorting_key;
|
||||
metadata.primary_key.definition_ast = nullptr;
|
||||
}
|
||||
|
||||
if (args.storage_def->sample_by)
|
||||
metadata.sampling_key = KeyDescription::getKeyFromAST(args.storage_def->sample_by->ptr(), metadata.columns, args.context);
|
||||
@ -521,6 +526,10 @@ static StoragePtr create(const StorageFactory::Arguments & args)
|
||||
for (auto & index : args.query.columns_list->indices->children)
|
||||
metadata.secondary_indices.push_back(IndexDescription::getIndexFromAST(index, args.columns, args.context));
|
||||
|
||||
if (args.query.columns_list && args.query.columns_list->constraints)
|
||||
for (auto & constraint : args.query.columns_list->constraints->children)
|
||||
metadata.constraints.constraints.push_back(constraint);
|
||||
|
||||
storage_settings->loadFromQuery(*args.storage_def);
|
||||
|
||||
if (args.storage_def->settings)
|
||||
|
@ -15,7 +15,7 @@ PARTITION BY date
|
||||
ORDER BY key;
|
||||
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(9);
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(9); ; --{serverError 469}
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(9); --{serverError 469}
|
||||
|
||||
SELECT * FROM table_for_rename ORDER BY key;
|
||||
|
||||
@ -26,7 +26,7 @@ SELECT * FROM table_for_rename ORDER BY key;
|
||||
|
||||
SELECT '-- insert after rename --';
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(10, 10);
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(10, 10); ; --{serverError 469}
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number) from numbers(10, 10); --{serverError 469}
|
||||
SELECT * FROM table_for_rename ORDER BY key;
|
||||
|
||||
SELECT '-- rename columns back --';
|
||||
@ -37,7 +37,7 @@ SELECT * FROM table_for_rename ORDER BY key;
|
||||
|
||||
SELECT '-- insert after rename column --';
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number + 1), toString(number + 2) from numbers(20,10);
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number), toString(number + 2) from numbers(20, 10); ; --{serverError 469}
|
||||
INSERT INTO table_for_rename SELECT toDate('2019-10-01') + number % 3, number, toString(number), toString(number), toString(number + 2) from numbers(20, 10); --{serverError 469}
|
||||
SELECT * FROM table_for_rename ORDER BY key;
|
||||
|
||||
DROP TABLE IF EXISTS table_for_rename;
|
||||
|
Loading…
Reference in New Issue
Block a user