Merge pull request #36803 from CurtizJ/fix-unflatten-nested

Fix creation of tables with `flatten_nested = 0`
This commit is contained in:
Kruglov Pavel 2022-05-02 13:58:16 +02:00 committed by GitHub
commit b98ac57090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -589,7 +589,7 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(
res.add(std::move(column));
}
if (context_->getSettingsRef().flatten_nested)
if (!attach && context_->getSettingsRef().flatten_nested)
res.flattenNested();
if (res.getAllPhysical().empty())

View File

@ -0,0 +1,4 @@
CREATE TABLE default.t_nested_detach\n(\n `n` Nested(u UInt32, s String)\n)\nENGINE = Log
n Nested(u UInt32, s String)
CREATE TABLE default.t_nested_detach\n(\n `n` Nested(u UInt32, s String)\n)\nENGINE = Log
n Nested(u UInt32, s String)

View File

@ -0,0 +1,17 @@
DROP TABLE IF EXISTS t_nested_detach;
SET flatten_nested = 0;
CREATE TABLE t_nested_detach (n Nested(u UInt32, s String)) ENGINE = Log;
SHOW CREATE TABLE t_nested_detach;
DESC TABLE t_nested_detach;
SET flatten_nested = 1;
DETACH TABLE t_nested_detach;
ATTACH TABLE t_nested_detach;
SHOW CREATE TABLE t_nested_detach;
DESC TABLE t_nested_detach;
DROP TABLE IF EXISTS t_nested_detach;