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

Function create

src/DataTypes/DataTypeTuple.cpp:467–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467static DataTypePtr create(const ASTPtr & arguments)
468{
469 if (!arguments || arguments->children.empty())
470 return std::make_shared<DataTypeTuple>(DataTypes{});
471
472 DataTypes nested_types;
473 nested_types.reserve(arguments->children.size());
474
475 Strings names;
476 names.reserve(arguments->children.size());
477
478 for (const ASTPtr & child : arguments->children)
479 {
480 if (const auto * name_and_type_pair = child->as<ASTNameTypePair>())
481 {
482 nested_types.emplace_back(DataTypeFactory::instance().get(name_and_type_pair->type));
483 names.emplace_back(name_and_type_pair->name);
484 }
485 else
486 nested_types.emplace_back(DataTypeFactory::instance().get(child));
487 }
488
489 if (names.empty())
490 return std::make_shared<DataTypeTuple>(nested_types);
491 if (names.size() != nested_types.size())
492 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Names are specified not for all elements of Tuple type");
493 return std::make_shared<DataTypeTuple>(nested_types, names);
494}
495
496
497void registerDataTypeTuple(DataTypeFactory & factory)

Callers 3

createColumnMethod · 0.70
doGetSerializationMethod · 0.70
getSerializationMethod · 0.70

Calls 6

ExceptionClass · 0.50
emptyMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected