MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getSubcolumnsOfNested

Function getSubcolumnsOfNested

src/DataTypes/NestedUtils.cpp:464–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462using NameToDataType = std::map<String, DataTypePtr>;
463
464NameToDataType getSubcolumnsOfNested(const NamesAndTypesList & names_and_types)
465{
466 std::unordered_map<String, NamesAndTypesList> nested;
467 for (const auto & name_type : names_and_types)
468 {
469 /// Skip subcolumns (e.g. `c0.c2.null` derived from `c0.c2 Array(Nullable(Tuple()))`).
470 /// They are not real flat-nested columns like `n.a Array(T)`, `n.b Array(T)`.
471 if (name_type.isSubcolumn())
472 continue;
473
474 const auto * type_arr = typeid_cast<const DataTypeArray *>(name_type.type.get());
475
476 /// Ignore true Nested type, but try to unite flatten arrays to Nested type.
477 if (!isNested(name_type.type) && type_arr)
478 {
479 auto split = splitName(name_type.name);
480 if (!split.second.empty())
481 nested[split.first].emplace_back(split.second, type_arr->getNestedType());
482 }
483 }
484
485 std::map<String, DataTypePtr> nested_types;
486
487 for (const auto & [name, elems] : nested)
488 nested_types.emplace(name, createNested(elems.getTypes(), elems.getNames()));
489
490 return nested_types;
491}
492
493}
494

Callers 2

collectFunction · 0.85
convertToSubcolumnsFunction · 0.85

Calls 11

isNestedFunction · 0.85
createNestedFunction · 0.85
isSubcolumnMethod · 0.80
getNestedTypeMethod · 0.80
splitNameFunction · 0.70
getMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
emplaceMethod · 0.45
getTypesMethod · 0.45
getNamesMethod · 0.45

Tested by

no test coverage detected