void MergeTreePartition::serializeText(const MergeTreeData & storage, WriteBuffer & out, const FormatSettings & format_settings) const { size_t key_size = storage.partition_key_sample.columns(); if (key_size == 0) { writeCString("tuple()", out); } else if (key_size == 1) { const DataTypePtr & type = storage.partition_key_sample.getByPosition(0).type; auto column = type->createColumn(); column->insert(value[0]); type->serializeAsText(*column, 0, out, format_settings); } else { DataTypes types; Columns columns; for (size_t i = 0; i < key_size; ++i) { const auto & type = storage.partition_key_sample.getByPosition(i).type; types.push_back(type); auto column = type->createColumn(); column->insert(value[i]); columns.push_back(std::move(column)); } DataTypeTuple tuple_type(types); auto tuple_column = ColumnTuple::create(columns); tuple_type.serializeText(*tuple_column, 0, out, format_settings); } }
DataTypes NamesAndTypesList::getTypes() const { DataTypes res; res.reserve(size()); for (const NameAndTypePair & column : *this) res.push_back(column.type); return res; }