diff --git a/src/DataTypes/NestedUtils.cpp b/src/DataTypes/NestedUtils.cpp index e988490a487..5f8b9f877bf 100644 --- a/src/DataTypes/NestedUtils.cpp +++ b/src/DataTypes/NestedUtils.cpp @@ -86,7 +86,8 @@ Block flatten(const Block & block) { if (const DataTypeArray * type_arr = typeid_cast(elem.type.get())) { - if (const DataTypeTuple * type_tuple = typeid_cast(type_arr->getNestedType().get())) + const DataTypeTuple * type_tuple = typeid_cast(type_arr->getNestedType().get()); + if (type_tuple && type_tuple->haveExplicitNames()) { const DataTypes & element_types = type_tuple->getElements(); const Strings & names = type_tuple->getElementNames(); diff --git a/src/DataTypes/NestedUtils.h b/src/DataTypes/NestedUtils.h index 098d98699e4..3039fd7f118 100644 --- a/src/DataTypes/NestedUtils.h +++ b/src/DataTypes/NestedUtils.h @@ -17,6 +17,7 @@ namespace Nested std::string extractTableName(const std::string & nested_name); /// Replace Array(Tuple(...)) columns to a multiple of Array columns in a form of `column_name.element_name`. + /// only for named tuples that actually represent Nested structures. Block flatten(const Block & block); /// Collect Array columns in a form of `column_name.element_name` to single Array(Tuple(...)) column. diff --git a/src/Storages/ColumnsDescription.h b/src/Storages/ColumnsDescription.h index 72399a70128..4fbb041d124 100644 --- a/src/Storages/ColumnsDescription.h +++ b/src/Storages/ColumnsDescription.h @@ -61,6 +61,7 @@ public: /// TODO add ability to rename nested columns void rename(const String & column_from, const String & column_to); + /// NOTE Must correspond with Nested::flatten function. void flattenNested(); /// TODO: remove, insert already flattened Nested columns. bool operator==(const ColumnsDescription & other) const { return columns == other.columns; } diff --git a/tests/queries/0_stateless/01254_array_of_unnamed_tuples.reference b/tests/queries/0_stateless/01254_array_of_unnamed_tuples.reference new file mode 100644 index 00000000000..0342c7b7310 --- /dev/null +++ b/tests/queries/0_stateless/01254_array_of_unnamed_tuples.reference @@ -0,0 +1,10 @@ +[(nan,1.1460459347849696e-169)] `xbguF 1493493065813843889 +[(-2.6774132404843463e217,-1.5941466176583548e-32)] ?/;UTko 8163231169061670909 +[(4.559039863342969e-218,1.1023812988249403e186)] k3Igp@ 9512519566588292358 +[(-6.156499824044965e254,2.125276757267567e176)] 12763761121429990320 +[] TlL 10781278062399783511 +[(-1.6511853645079817e-21,-1.5094564365588905e303)] UeS}D 1158449958889177529 +[(-5.109297304033652e229,-8.565674764550042e219),(-2.163260216301827e-75,-3.771562357185976e285)] 0Z3|h 12502841092151487477 +[] -] 2092132020040612180 +[(-2.9588901009588613e-146,-6.4241843242744556e268)] &b!M-e;7 10616749141511339887 +[(3.084905744030789e-98,-4.973771413288743e177),(-1.8198487259356486e114,1.2449864950522508e251)] Dj7peUH{T 5992776369613298329 diff --git a/tests/queries/0_stateless/01254_array_of_unnamed_tuples.sql b/tests/queries/0_stateless/01254_array_of_unnamed_tuples.sql new file mode 100644 index 00000000000..3660d66620c --- /dev/null +++ b/tests/queries/0_stateless/01254_array_of_unnamed_tuples.sql @@ -0,0 +1,5 @@ +DROP TABLE IF EXISTS mass_table_457; +CREATE TABLE mass_table_457 (key Array(Tuple(Float64, Float64)), name String, value UInt64) ENGINE = Memory; +INSERT INTO mass_table_457 SELECT * FROM generateRandom('`key` Array(Tuple(Float64, Float64)),`name` String,`value` UInt64', 1, 10, 2) LIMIT 10; +SELECT * FROM mass_table_457; +DROP TABLE mass_table_457; diff --git a/tests/queries/0_stateless/01255_geo_types_livace.reference b/tests/queries/0_stateless/01255_geo_types_livace.reference new file mode 100644 index 00000000000..3982d6fb18a --- /dev/null +++ b/tests/queries/0_stateless/01255_geo_types_livace.reference @@ -0,0 +1,2 @@ +[(123,456),(789,234)] [(567,890)] +[] [(11,22),(33,44),(55,66)] diff --git a/tests/queries/0_stateless/01255_geo_types_livace.sql b/tests/queries/0_stateless/01255_geo_types_livace.sql new file mode 100644 index 00000000000..0838f0fa219 --- /dev/null +++ b/tests/queries/0_stateless/01255_geo_types_livace.sql @@ -0,0 +1,9 @@ +DROP TABLE IF EXISTS tutorial; +create table tutorial ( inner_poly Array(Tuple(Int32, Int32)), outer_poly Array(Tuple(Int32, Int32)) ) engine = Log(); + +SELECT * FROM tutorial; + +INSERT INTO tutorial VALUES ([(123, 456), (789, 234)], [(567, 890)]), ([], [(11, 22), (33, 44), (55, 66)]); +SELECT * FROM tutorial; + +DROP TABLE tutorial;