fix nested and scalar columns with dot

This commit is contained in:
Anton Popov 2021-09-02 20:22:01 +03:00
parent be4c9102d8
commit ee7f50396b
3 changed files with 31 additions and 1 deletions

View File

@ -141,7 +141,7 @@ NamesAndTypesList collect(const NamesAndTypesList & names_and_types)
auto nested_types = getSubcolumnsOfNested(names_and_types);
for (const auto & name_type : names_and_types)
if (!nested_types.count(splitName(name_type.name).first))
if (!isArray(name_type.type) || !nested_types.count(splitName(name_type.name).first))
res.push_back(name_type);
for (const auto & name_type : nested_types)
@ -157,6 +157,9 @@ NamesAndTypesList convertToSubcolumns(const NamesAndTypesList & names_and_types)
for (auto & name_type : res)
{
if (!isArray(name_type.type))
continue;
auto split = splitName(name_type.name);
if (name_type.isSubcolumn() || split.second.empty())
continue;

View File

@ -0,0 +1,3 @@
1 [0,0] 2 [1,1,3]
1 [0,0] 2 [1,1,3]
1 [0,0] 2 [1,1,3]

View File

@ -0,0 +1,24 @@
DROP TABLE IF EXISTS t_with_dots;
CREATE TABLE t_with_dots (id UInt32, arr Array(UInt32), `b.id` UInt32, `b.arr` Array(UInt32)) ENGINE = Log;
INSERT INTO t_with_dots VALUES (1, [0, 0], 2, [1, 1, 3]);
SELECT * FROM t_with_dots;
DROP TABLE t_with_dots;
CREATE TABLE t_with_dots (id UInt32, arr Array(UInt32), `b.id` UInt32, `b.arr` Array(UInt32))
ENGINE = MergeTree ORDER BY id;
INSERT INTO t_with_dots VALUES (1, [0, 0], 2, [1, 1, 3]);
SELECT * FROM t_with_dots;
DROP TABLE t_with_dots;
CREATE TABLE t_with_dots (id UInt32, arr Array(UInt32), `b.id` UInt32, `b.arr` Array(UInt32))
ENGINE = MergeTree ORDER BY id
SETTINGS min_bytes_for_wide_part = 0;
INSERT INTO t_with_dots VALUES (1, [0, 0], 2, [1, 1, 3]);
SELECT * FROM t_with_dots;
DROP TABLE t_with_dots;