This commit is contained in:
Alexander Tokmakov 2020-09-01 20:55:35 +03:00
parent 56695727b2
commit 41dd393824
5 changed files with 12 additions and 10 deletions

View File

@ -254,9 +254,12 @@ void DatabaseOrdinary::alterTable(const Context & context, const StorageID & tab
auto & ast_create_query = ast->as<ASTCreateQuery &>();
if (ast_create_query.as_table_function)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot alter table {} because it was created AS table function", backQuote(table_name));
bool has_structure = ast_create_query.columns_list && ast_create_query.columns_list->columns;
if (ast_create_query.as_table_function && !has_structure)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Cannot alter table {} because it was created AS table function"
" and doesn't have structure in metadata", backQuote(table_name));
assert(has_structure);
ASTPtr new_columns = InterpreterCreateQuery::formatColumns(metadata.columns);
ASTPtr new_indices = InterpreterCreateQuery::formatIndices(metadata.secondary_indices);
ASTPtr new_constraints = InterpreterCreateQuery::formatConstraints(metadata.constraints);

View File

@ -58,6 +58,7 @@ SRCS(
ExtractExpressionInfoVisitor.cpp
FillingRow.cpp
getClusterName.cpp
getHeaderForProcessingStage.cpp
getTableExpressions.cpp
HashJoin.cpp
IdentifierSemantic.cpp

View File

@ -37,6 +37,7 @@ public:
auto nested_storage = get_nested();
nested_storage->startup();
nested_storage->renameInMemory(getStorageID());
nested = nested_storage;
get_nested = {};
return nested;

View File

@ -1,7 +1,6 @@
CREATE TABLE default.table_from_remote AS remote(\'localhost\', \'system\', \'numbers\')
CREATE TABLE default.table_from_remote AS remote(\'localhost\', \'system\', \'numbers\')
CREATE TABLE default.table_from_numbers AS numbers(1000)
CREATE TABLE default.table_from_numbers AS numbers(1000)
CREATE TABLE default.table_from_remote\n(\n `number` UInt64\n) AS remote(\'localhost\', \'system\', \'numbers\')
CREATE TABLE default.table_from_remote\n(\n `number` UInt64,\n `col` UInt8\n) AS remote(\'localhost\', \'system\', \'numbers\')
CREATE TABLE default.table_from_numbers\n(\n `number` UInt64\n) AS numbers(1000)
CREATE TABLE default.table_from_numbers\n(\n `number` UInt64\n) AS numbers(1000)
CREATE TABLE default.table_from_select\n(\n `number` UInt64\n)\nENGINE = MergeTree()\nORDER BY tuple()\nSETTINGS index_granularity = 8192
CREATE TABLE default.table_from_select\n(\n `number` UInt64,\n `col` UInt8\n)\nENGINE = MergeTree()\nORDER BY tuple()\nSETTINGS index_granularity = 8192
1

View File

@ -6,7 +6,7 @@ CREATE TABLE table_from_remote AS remote('localhost', 'system', 'numbers');
SHOW CREATE TABLE table_from_remote;
ALTER TABLE table_from_remote ADD COLUMN col UInt8; --{serverError 48}
ALTER TABLE table_from_remote ADD COLUMN col UInt8;
SHOW CREATE TABLE table_from_remote;
@ -26,8 +26,6 @@ ALTER TABLE table_from_select ADD COLUMN col UInt8;
SHOW CREATE TABLE table_from_select;
SELECT 1;
DROP TABLE IF EXISTS table_from_remote;
DROP TABLE IF EXISTS table_from_select;
DROP TABLE IF EXISTS table_from_numbers;