Merge pull request #34228 from CurtizJ/fix-subcolumns-with-dots

Fix reading of subcolumns with dots in their names
This commit is contained in:
Anton Popov 2022-02-07 19:01:33 +03:00 committed by GitHub
commit b633a916af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 2 deletions

View File

@ -167,8 +167,10 @@ String getNameForSubstreamPath(
/// Because nested data may be represented not by Array of Tuple,
/// but by separate Array columns with names in a form of a.b,
/// and name is encoded as a whole.
stream_name += (escape_tuple_delimiter && it->escape_tuple_delimiter ?
escapeForFileName(".") : ".") + escapeForFileName(it->tuple_element_name);
if (escape_tuple_delimiter && it->escape_tuple_delimiter)
stream_name += escapeForFileName("." + it->tuple_element_name);
else
stream_name += "." + it->tuple_element_name;
}
}

View File

@ -0,0 +1,7 @@
[1] [[1]]
[[1]]
[(1,[1])]
[[1]]
(('a',1),'b')
a 1
a b

View File

@ -0,0 +1,33 @@
DROP TABLE IF EXISTS t_nested_with_dots;
CREATE TABLE t_nested_with_dots (n Nested(id UInt64, `values.id` Array(UInt64)))
ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t_nested_with_dots VALUES ([1], [[1]]);
SELECT * FROM t_nested_with_dots;
SELECT n.values.id FROM t_nested_with_dots;
DROP TABLE IF EXISTS t_nested_with_dots;
SET flatten_nested = 0;
CREATE TABLE t_nested_with_dots (n Nested(id UInt64, `values.id` Array(UInt64)))
ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t_nested_with_dots VALUES ([(1, [1])]);
SELECT * FROM t_nested_with_dots;
SELECT n.values.id FROM t_nested_with_dots;
DROP TABLE IF EXISTS t_nested_with_dots;
CREATE TABLE t_nested_with_dots (`t.t2` Tuple(`t3.t4.t5` Tuple(`s1.s2` String, `u1.u2` UInt64), `s3.s4.s5` String))
ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t_nested_with_dots VALUES ((('a', 1), 'b'));
SELECT * FROM t_nested_with_dots;
SELECT t.t2.t3.t4.t5.s1.s2, t.t2.t3.t4.t5.u1.u2 FROM t_nested_with_dots;
SELECT t.t2.t3.t4.t5.s1.s2, t.t2.s3.s4.s5 FROM t_nested_with_dots;
DROP TABLE IF EXISTS t_nested_with_dots;