mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
fix crash in CREATE AS
This commit is contained in:
parent
11f56186db
commit
8352e5d202
@ -630,7 +630,12 @@ void InterpreterCreateQuery::setEngine(ASTCreateQuery & create) const
|
||||
"Cannot CREATE a table AS " + qualified_name + ", it is a Dictionary",
|
||||
ErrorCodes::INCORRECT_QUERY);
|
||||
|
||||
create.set(create.storage, as_create.storage->ptr());
|
||||
if (as_create.storage)
|
||||
create.set(create.storage, as_create.storage->ptr());
|
||||
else if (as_create.as_table_function)
|
||||
create.as_table_function = as_create.as_table_function->clone();
|
||||
else
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot set engine, it's a bug.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
CREATE TABLE default.table2\n(\n `number` UInt64\n) AS numbers(5)
|
||||
CREATE TABLE default.table3\n(\n `number` UInt64\n) AS numbers(5)
|
||||
5 10
|
||||
5 10
|
@ -0,0 +1,14 @@
|
||||
DROP TABLE IF EXISTS table2;
|
||||
DROP TABLE IF EXISTS table3;
|
||||
|
||||
CREATE TABLE table2 AS numbers(5);
|
||||
CREATE TABLE table3 AS table2;
|
||||
|
||||
SHOW CREATE table2;
|
||||
SHOW CREATE table3;
|
||||
|
||||
SELECT count(), sum(number) FROM table2;
|
||||
SELECT count(), sum(number) FROM table3;
|
||||
|
||||
DROP TABLE table2;
|
||||
DROP TABLE table3;
|
Loading…
Reference in New Issue
Block a user