diff --git a/dbms/src/Columns/ColumnExpression.cpp b/dbms/src/Columns/ColumnExpression.cpp index c6e72c5b273..9db3fba0a69 100644 --- a/dbms/src/Columns/ColumnExpression.cpp +++ b/dbms/src/Columns/ColumnExpression.cpp @@ -12,6 +12,13 @@ ColumnExpression::ColumnExpression( s = s_; } +ColumnExpression::ColumnExpression( + size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypesList & arguments_, const DataTypePtr & return_type_, const String & return_name_) + : expression(expression_), arguments(arguments_.begin(), arguments_.end()), return_type(return_type_), return_name(return_name_) +{ + s = s_; +} + MutableColumnPtr ColumnExpression::cloneDummy(size_t s_) const { return ColumnExpression::create(s_, expression, arguments, return_type, return_name); diff --git a/dbms/src/Columns/ColumnExpression.h b/dbms/src/Columns/ColumnExpression.h index 585fa1254dd..cfbd8cb5353 100644 --- a/dbms/src/Columns/ColumnExpression.h +++ b/dbms/src/Columns/ColumnExpression.h @@ -20,6 +20,7 @@ private: using ExpressionActionsPtr = std::shared_ptr; ColumnExpression(size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypes & arguments_, const DataTypePtr & return_type_, const String & return_name_); + ColumnExpression(size_t s_, const ExpressionActionsPtr & expression_, const NamesAndTypesList & arguments_, const DataTypePtr & return_type_, const String & return_name_); ColumnExpression(const ColumnExpression &) = default; diff --git a/dbms/src/Common/ExternalTable.h b/dbms/src/Common/ExternalTable.h index 33cd43bd41c..624604d30a1 100644 --- a/dbms/src/Common/ExternalTable.h +++ b/dbms/src/Common/ExternalTable.h @@ -197,8 +197,8 @@ public: ExternalTableData data = getData(context); /// Create table - NamesAndTypes columns = sample_block.getNamesAndTypes(); - StoragePtr storage = StorageMemory::create(data.second, columns, NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}); + NamesAndTypesList columns = sample_block.getNamesAndTypesList(); + StoragePtr storage = StorageMemory::create(data.second, columns, NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}); storage->startup(); context.addExternalTable(data.second, storage); BlockOutputStreamPtr output = storage->write(ASTPtr(), context.getSettingsRef()); diff --git a/dbms/src/Core/Block.cpp b/dbms/src/Core/Block.cpp index f84b9c8f4c0..328aa6074f0 100644 --- a/dbms/src/Core/Block.cpp +++ b/dbms/src/Core/Block.cpp @@ -356,9 +356,9 @@ const ColumnsWithTypeAndName & Block::getColumnsWithTypeAndName() const } -NamesAndTypes Block::getNamesAndTypes() const +NamesAndTypesList Block::getNamesAndTypesList() const { - NamesAndTypes res; + NamesAndTypesList res; for (const auto & elem : data) res.emplace_back(elem.name, elem.type); diff --git a/dbms/src/Core/Block.h b/dbms/src/Core/Block.h index f3b204cd76e..0513f50456e 100644 --- a/dbms/src/Core/Block.h +++ b/dbms/src/Core/Block.h @@ -77,7 +77,7 @@ public: size_t getPositionByName(const std::string & name) const; const ColumnsWithTypeAndName & getColumnsWithTypeAndName() const; - NamesAndTypes getNamesAndTypes() const; + NamesAndTypesList getNamesAndTypesList() const; Names getNames() const; /// Returns number of rows from first column in block, not equal to nullptr. If no columns, returns 0. diff --git a/dbms/src/Core/NamesAndTypes.cpp b/dbms/src/Core/NamesAndTypes.cpp index 24aba9e9a3a..d49c711fb6f 100644 --- a/dbms/src/Core/NamesAndTypes.cpp +++ b/dbms/src/Core/NamesAndTypes.cpp @@ -18,7 +18,7 @@ namespace ErrorCodes } -void NamesAndTypes::readText(ReadBuffer & buf) +void NamesAndTypesList::readText(ReadBuffer & buf) { const DataTypeFactory & data_type_factory = DataTypeFactory::instance(); @@ -27,7 +27,7 @@ void NamesAndTypes::readText(ReadBuffer & buf) DB::readText(count, buf); assertString(" columns:\n", buf); resize(count); - for (NameAndType & it : *this) + for (NameAndTypePair & it : *this) { readBackQuotedStringWithSQLStyle(it.name, buf); assertChar(' ', buf); @@ -38,7 +38,7 @@ void NamesAndTypes::readText(ReadBuffer & buf) } } -void NamesAndTypes::writeText(WriteBuffer & buf) const +void NamesAndTypesList::writeText(WriteBuffer & buf) const { writeString("columns format version: 1\n", buf); DB::writeText(size(), buf); @@ -52,23 +52,23 @@ void NamesAndTypes::writeText(WriteBuffer & buf) const } } -String NamesAndTypes::toString() const +String NamesAndTypesList::toString() const { WriteBufferFromOwnString out; writeText(out); return out.str(); } -NamesAndTypes NamesAndTypes::parse(const String & s) +NamesAndTypesList NamesAndTypesList::parse(const String & s) { ReadBufferFromString in(s); - NamesAndTypes res; + NamesAndTypesList res; res.readText(in); assertEOF(in); return res; } -bool NamesAndTypes::isSubsetOf(const NamesAndTypes & rhs) const +bool NamesAndTypesList::isSubsetOf(const NamesAndTypesList & rhs) const { NamesAndTypes vector(rhs.begin(), rhs.end()); vector.insert(vector.end(), begin(), end()); @@ -76,7 +76,7 @@ bool NamesAndTypes::isSubsetOf(const NamesAndTypes & rhs) const return std::unique(vector.begin(), vector.end()) == vector.begin() + rhs.size(); } -size_t NamesAndTypes::sizeOfDifference(const NamesAndTypes & rhs) const +size_t NamesAndTypesList::sizeOfDifference(const NamesAndTypesList & rhs) const { NamesAndTypes vector(rhs.begin(), rhs.end()); vector.insert(vector.end(), begin(), end()); @@ -84,39 +84,43 @@ size_t NamesAndTypes::sizeOfDifference(const NamesAndTypes & rhs) const return (std::unique(vector.begin(), vector.end()) - vector.begin()) * 2 - size() - rhs.size(); } -Names NamesAndTypes::getNames() const +Names NamesAndTypesList::getNames() const { Names res; res.reserve(size()); - for (const NameAndType & column : *this) + for (const NameAndTypePair & column : *this) + { res.push_back(column.name); + } return res; } -NamesAndTypes NamesAndTypes::filter(const NameSet & names) const +NamesAndTypesList NamesAndTypesList::filter(const NameSet & names) const { - NamesAndTypes res; - for (const NameAndType & column : *this) + NamesAndTypesList res; + for (const NameAndTypePair & column : *this) + { if (names.count(column.name)) res.push_back(column); + } return res; } -NamesAndTypes NamesAndTypes::filter(const Names & names) const +NamesAndTypesList NamesAndTypesList::filter(const Names & names) const { return filter(NameSet(names.begin(), names.end())); } -NamesAndTypes NamesAndTypes::addTypes(const Names & names) const +NamesAndTypesList NamesAndTypesList::addTypes(const Names & names) const { /// NOTE It's better to make a map in `IStorage` than to create it here every time again. google::dense_hash_map types; types.set_empty_key(StringRef()); - for (const NameAndType & column : *this) + for (const NameAndTypePair & column : *this) types[column.name] = &column.type; - NamesAndTypes res; + NamesAndTypesList res; for (const String & name : names) { auto it = types.find(name); diff --git a/dbms/src/Core/NamesAndTypes.h b/dbms/src/Core/NamesAndTypes.h index 786b297f38d..1eb95d3cd51 100644 --- a/dbms/src/Core/NamesAndTypes.h +++ b/dbms/src/Core/NamesAndTypes.h @@ -1,7 +1,9 @@ #pragma once +#include +#include #include -#include +#include #include #include @@ -11,58 +13,61 @@ namespace DB { -struct NameAndType +struct NameAndTypePair { String name; DataTypePtr type; - NameAndType() {} - NameAndType(const String & name_, const DataTypePtr & type_) : name(name_), type(type_) {} + NameAndTypePair() {} + NameAndTypePair(const String & name_, const DataTypePtr & type_) : name(name_), type(type_) {} - bool operator<(const NameAndType & rhs) const + bool operator<(const NameAndTypePair & rhs) const { return std::forward_as_tuple(name, type->getName()) < std::forward_as_tuple(rhs.name, rhs.type->getName()); } - bool operator==(const NameAndType & rhs) const + bool operator==(const NameAndTypePair & rhs) const { return name == rhs.name && type->equals(*rhs.type); } }; -class NamesAndTypes : public std::vector +using NamesAndTypes = std::vector; + +class NamesAndTypesList : public std::list { public: - NamesAndTypes() {} + NamesAndTypesList() {} - NamesAndTypes(std::initializer_list init) : std::vector(init) {} + NamesAndTypesList(std::initializer_list init) : std::list(init) {} template - NamesAndTypes(Iterator begin, Iterator end) : std::vector(begin, end) {} + NamesAndTypesList(Iterator begin, Iterator end) : std::list(begin, end) {} + void readText(ReadBuffer & buf); void writeText(WriteBuffer & buf) const; String toString() const; - static NamesAndTypes parse(const String & s); + static NamesAndTypesList parse(const String & s); /// All `rhs` elements must be different. - bool isSubsetOf(const NamesAndTypes & rhs) const; + bool isSubsetOf(const NamesAndTypesList & rhs) const; /// Hamming distance between sets /// (in other words, the added and deleted columns are counted once, the columns that changed the type - twice). - size_t sizeOfDifference(const NamesAndTypes & rhs) const; + size_t sizeOfDifference(const NamesAndTypesList & rhs) const; Names getNames() const; /// Leave only the columns whose names are in the `names`. In `names` there can be superfluous columns. - NamesAndTypes filter(const NameSet & names) const; + NamesAndTypesList filter(const NameSet & names) const; /// Leave only the columns whose names are in the `names`. In `names` there can be superfluous columns. - NamesAndTypes filter(const Names & names) const; + NamesAndTypesList filter(const Names & names) const; /// Unlike `filter`, returns columns in the order in which they go in `names`. - NamesAndTypes addTypes(const Names & names) const; + NamesAndTypesList addTypes(const Names & names) const; }; } diff --git a/dbms/src/Core/iostream_debug_helpers.cpp b/dbms/src/Core/iostream_debug_helpers.cpp index c50c0b53b38..cb6cc4a8dbb 100644 --- a/dbms/src/Core/iostream_debug_helpers.cpp +++ b/dbms/src/Core/iostream_debug_helpers.cpp @@ -29,9 +29,9 @@ std::ostream & operator<<(std::ostream & stream, const Field & what) return stream; } -std::ostream & operator<<(std::ostream & stream, const NameAndType & what) +std::ostream & operator<<(std::ostream & stream, const NameAndTypePair & what) { - stream << "NameAndType(name = " << what.name << ", type = " << what.type << ")"; + stream << "NameAndTypePair(name = " << what.name << ", type = " << what.type << ")"; return stream; } diff --git a/dbms/src/Core/iostream_debug_helpers.h b/dbms/src/Core/iostream_debug_helpers.h index 10839047e87..ac801ac7382 100644 --- a/dbms/src/Core/iostream_debug_helpers.h +++ b/dbms/src/Core/iostream_debug_helpers.h @@ -13,8 +13,8 @@ std::ostream & operator<<(std::ostream & stream, const IBlockInputStream & what) class Field; std::ostream & operator<<(std::ostream & stream, const Field & what); -struct NameAndType; -std::ostream & operator<<(std::ostream & stream, const NameAndType & what); +struct NameAndTypePair; +std::ostream & operator<<(std::ostream & stream, const NameAndTypePair & what); class IDataType; std::ostream & operator<<(std::ostream & stream, const IDataType & what); diff --git a/dbms/src/DataStreams/AddingDefaultBlockOutputStream.h b/dbms/src/DataStreams/AddingDefaultBlockOutputStream.h index 00c68bbe0fe..9ac92e74ac9 100644 --- a/dbms/src/DataStreams/AddingDefaultBlockOutputStream.h +++ b/dbms/src/DataStreams/AddingDefaultBlockOutputStream.h @@ -19,7 +19,7 @@ class AddingDefaultBlockOutputStream : public IBlockOutputStream public: AddingDefaultBlockOutputStream( const BlockOutputStreamPtr & output_, - NamesAndTypes required_columns_, + NamesAndTypesList required_columns_, const ColumnDefaults & column_defaults_, const Context & context_, bool only_explicit_column_defaults_) @@ -38,7 +38,7 @@ public: private: BlockOutputStreamPtr output; - NamesAndTypes required_columns; + NamesAndTypesList required_columns; const ColumnDefaults column_defaults; const Context & context; bool only_explicit_column_defaults; diff --git a/dbms/src/DataStreams/JSONRowOutputStream.cpp b/dbms/src/DataStreams/JSONRowOutputStream.cpp index f2673704725..05783c19341 100644 --- a/dbms/src/DataStreams/JSONRowOutputStream.cpp +++ b/dbms/src/DataStreams/JSONRowOutputStream.cpp @@ -9,7 +9,7 @@ namespace DB JSONRowOutputStream::JSONRowOutputStream(WriteBuffer & ostr_, const Block & sample_, bool write_statistics_, const FormatSettingsJSON & settings_) : dst_ostr(ostr_), write_statistics(write_statistics_), settings(settings_) { - NamesAndTypes columns(sample_.getNamesAndTypes()); + NamesAndTypesList columns(sample_.getNamesAndTypesList()); fields.assign(columns.begin(), columns.end()); bool need_validate_utf8 = false; diff --git a/dbms/src/DataStreams/ProhibitColumnsBlockOutputStream.h b/dbms/src/DataStreams/ProhibitColumnsBlockOutputStream.h index 2758b764bf9..732eece7904 100644 --- a/dbms/src/DataStreams/ProhibitColumnsBlockOutputStream.h +++ b/dbms/src/DataStreams/ProhibitColumnsBlockOutputStream.h @@ -11,7 +11,7 @@ namespace DB class ProhibitColumnsBlockOutputStream : public IBlockOutputStream { public: - ProhibitColumnsBlockOutputStream(const BlockOutputStreamPtr & output, const NamesAndTypes & columns) + ProhibitColumnsBlockOutputStream(const BlockOutputStreamPtr & output, const NamesAndTypesList & columns) : output{output}, columns{columns} { } @@ -25,7 +25,7 @@ private: void writeSuffix() override { output->writeSuffix(); } BlockOutputStreamPtr output; - NamesAndTypes columns; + NamesAndTypesList columns; }; } diff --git a/dbms/src/DataStreams/TSKVRowOutputStream.cpp b/dbms/src/DataStreams/TSKVRowOutputStream.cpp index a12ed3e9195..36c6cabef34 100644 --- a/dbms/src/DataStreams/TSKVRowOutputStream.cpp +++ b/dbms/src/DataStreams/TSKVRowOutputStream.cpp @@ -9,7 +9,7 @@ namespace DB TSKVRowOutputStream::TSKVRowOutputStream(WriteBuffer & ostr_, const Block & sample_) : TabSeparatedRowOutputStream(ostr_, sample_) { - NamesAndTypes columns(sample_.getNamesAndTypes()); + NamesAndTypesList columns(sample_.getNamesAndTypesList()); fields.assign(columns.begin(), columns.end()); for (auto & field : fields) diff --git a/dbms/src/DataStreams/XMLRowOutputStream.cpp b/dbms/src/DataStreams/XMLRowOutputStream.cpp index 5337f8de6be..cd7203f7a0b 100644 --- a/dbms/src/DataStreams/XMLRowOutputStream.cpp +++ b/dbms/src/DataStreams/XMLRowOutputStream.cpp @@ -9,7 +9,7 @@ namespace DB XMLRowOutputStream::XMLRowOutputStream(WriteBuffer & ostr_, const Block & sample_, bool write_statistics_) : dst_ostr(ostr_), write_statistics(write_statistics_) { - NamesAndTypes columns(sample_.getNamesAndTypes()); + NamesAndTypesList columns(sample_.getNamesAndTypesList()); fields.assign(columns.begin(), columns.end()); field_tag_names.resize(sample_.columns()); diff --git a/dbms/src/DataStreams/tests/expression_stream.cpp b/dbms/src/DataStreams/tests/expression_stream.cpp index c8a2cba74f4..f52a8f9c105 100644 --- a/dbms/src/DataStreams/tests/expression_stream.cpp +++ b/dbms/src/DataStreams/tests/expression_stream.cpp @@ -35,7 +35,7 @@ try Context context = Context::createGlobal(); - ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared())}); + ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared())}); ExpressionActionsChain chain; analyzer.appendSelect(chain, false); analyzer.appendProjectResult(chain); diff --git a/dbms/src/DataStreams/tests/filter_stream.cpp b/dbms/src/DataStreams/tests/filter_stream.cpp index 73b50e69885..1f5549204b0 100644 --- a/dbms/src/DataStreams/tests/filter_stream.cpp +++ b/dbms/src/DataStreams/tests/filter_stream.cpp @@ -41,7 +41,7 @@ try Context context = Context::createGlobal(); - ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared())}); + ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared())}); ExpressionActionsChain chain; analyzer.appendSelect(chain, false); analyzer.appendProjectResult(chain); diff --git a/dbms/src/DataStreams/tests/filter_stream_hitlog.cpp b/dbms/src/DataStreams/tests/filter_stream_hitlog.cpp index 0a929063379..4561ffde4be 100644 --- a/dbms/src/DataStreams/tests/filter_stream_hitlog.cpp +++ b/dbms/src/DataStreams/tests/filter_stream_hitlog.cpp @@ -33,7 +33,7 @@ int main(int, char **) try { - NamesAndTypes names_and_types_list + NamesAndTypesList names_and_types_list { {"WatchID", std::make_shared()}, {"JavaEnable", std::make_shared()}, @@ -106,7 +106,7 @@ int main(int, char **) /// create an object of an existing hit log table StoragePtr table = StorageLog::create("./", "HitLog", names_and_types_list, - NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); + NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); table->startup(); /// read from it, apply the expression, filter, and write in tsv form to the console diff --git a/dbms/src/DataStreams/tests/fork_streams.cpp b/dbms/src/DataStreams/tests/fork_streams.cpp index 7d43aa333dd..094533cc477 100644 --- a/dbms/src/DataStreams/tests/fork_streams.cpp +++ b/dbms/src/DataStreams/tests/fork_streams.cpp @@ -58,7 +58,7 @@ try Context context = Context::createGlobal(); - ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared())}); + ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared())}); ExpressionActionsChain chain; analyzer.appendSelect(chain, false); analyzer.appendProjectResult(chain); diff --git a/dbms/src/DataStreams/tests/native_streams.cpp b/dbms/src/DataStreams/tests/native_streams.cpp index 61bc8f763af..d06d8aa3714 100644 --- a/dbms/src/DataStreams/tests/native_streams.cpp +++ b/dbms/src/DataStreams/tests/native_streams.cpp @@ -28,7 +28,7 @@ try { using namespace DB; - NamesAndTypes names_and_types_list + NamesAndTypesList names_and_types_list { {"WatchID", std::make_shared()}, {"JavaEnable", std::make_shared()}, @@ -96,7 +96,7 @@ try /// create an object of an existing hit log table StoragePtr table = StorageLog::create("./", "HitLog", names_and_types_list, - NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); + NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); table->startup(); /// read from it diff --git a/dbms/src/DataStreams/tests/sorting_stream.cpp b/dbms/src/DataStreams/tests/sorting_stream.cpp index 7b0a76e2328..d3a32f4adf1 100644 --- a/dbms/src/DataStreams/tests/sorting_stream.cpp +++ b/dbms/src/DataStreams/tests/sorting_stream.cpp @@ -32,7 +32,7 @@ using namespace DB; int main(int argc, char ** argv) try { - NamesAndTypes names_and_types_list + NamesAndTypesList names_and_types_list { {"WatchID", std::make_shared()}, {"JavaEnable", std::make_shared()}, @@ -108,7 +108,7 @@ try /// create an object of an existing hit log table StoragePtr table = StorageLog::create("./", "HitLog", names_and_types_list, - NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); + NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); table->startup(); /// read from it, sort it, and write it in tsv form to the console diff --git a/dbms/src/DataTypes/NestedUtils.cpp b/dbms/src/DataTypes/NestedUtils.cpp index 48a583add4f..7d76b6a95aa 100644 --- a/dbms/src/DataTypes/NestedUtils.cpp +++ b/dbms/src/DataTypes/NestedUtils.cpp @@ -1,5 +1,4 @@ #include -#include #include @@ -48,9 +47,9 @@ std::string extractElementName(const std::string & nested_name) } -NamesAndTypes flatten(const NamesAndTypes & names_and_types) +NamesAndTypesList flatten(const NamesAndTypesList & names_and_types) { - NamesAndTypes res; + NamesAndTypesList res; for (const auto & name_type : names_and_types) { @@ -78,7 +77,7 @@ NamesAndTypes flatten(const NamesAndTypes & names_and_types) return res; } -NamesAndTypes collect(const NamesAndTypes & names_and_types) +NamesAndTypesList collect(const NamesAndTypesList & names_and_types) { return names_and_types; // TODO } diff --git a/dbms/src/DataTypes/NestedUtils.h b/dbms/src/DataTypes/NestedUtils.h index afd662b36e2..cd852719083 100644 --- a/dbms/src/DataTypes/NestedUtils.h +++ b/dbms/src/DataTypes/NestedUtils.h @@ -16,10 +16,10 @@ namespace Nested std::string extractElementName(const std::string & nested_name); /// Replace Array(Tuple(...)) columns to a multiple of Array columns in a form of `column_name.element_name`. - NamesAndTypes flatten(const NamesAndTypes & names_and_types); + NamesAndTypesList flatten(const NamesAndTypesList & names_and_types); /// Collect Array columns in a form of `column_name.element_name` to single Array(Tuple(...)) column. - NamesAndTypes collect(const NamesAndTypes & names_and_types); + NamesAndTypesList collect(const NamesAndTypesList & names_and_types); }; } diff --git a/dbms/src/Databases/DatabaseDictionary.cpp b/dbms/src/Databases/DatabaseDictionary.cpp index 6920f26078b..17a32c0ff78 100644 --- a/dbms/src/Databases/DatabaseDictionary.cpp +++ b/dbms/src/Databases/DatabaseDictionary.cpp @@ -139,9 +139,9 @@ void DatabaseDictionary::renameTable( void DatabaseDictionary::alterTable( const Context &, const String &, - const NamesAndTypes &, - const NamesAndTypes &, - const NamesAndTypes &, + const NamesAndTypesList &, + const NamesAndTypesList &, + const NamesAndTypesList &, const ColumnDefaults &, const ASTModifier &) { diff --git a/dbms/src/Databases/DatabaseDictionary.h b/dbms/src/Databases/DatabaseDictionary.h index 70f84c206ba..0aeba8db629 100644 --- a/dbms/src/Databases/DatabaseDictionary.h +++ b/dbms/src/Databases/DatabaseDictionary.h @@ -79,9 +79,9 @@ public: void alterTable( const Context & context, const String & name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const ASTModifier & engine_modifier) override; diff --git a/dbms/src/Databases/DatabaseMemory.cpp b/dbms/src/Databases/DatabaseMemory.cpp index b57b6596259..1191339bbeb 100644 --- a/dbms/src/Databases/DatabaseMemory.cpp +++ b/dbms/src/Databases/DatabaseMemory.cpp @@ -104,9 +104,9 @@ void DatabaseMemory::renameTable( void DatabaseMemory::alterTable( const Context &, const String &, - const NamesAndTypes &, - const NamesAndTypes &, - const NamesAndTypes &, + const NamesAndTypesList &, + const NamesAndTypesList &, + const NamesAndTypesList &, const ColumnDefaults &, const ASTModifier &) { diff --git a/dbms/src/Databases/DatabaseMemory.h b/dbms/src/Databases/DatabaseMemory.h index 7240a869b38..662d8d0b6ae 100644 --- a/dbms/src/Databases/DatabaseMemory.h +++ b/dbms/src/Databases/DatabaseMemory.h @@ -70,9 +70,9 @@ public: void alterTable( const Context & context, const String & name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const ASTModifier & engine_modifier) override; diff --git a/dbms/src/Databases/DatabaseOrdinary.cpp b/dbms/src/Databases/DatabaseOrdinary.cpp index 7dd6607c244..9510f0a0704 100644 --- a/dbms/src/Databases/DatabaseOrdinary.cpp +++ b/dbms/src/Databases/DatabaseOrdinary.cpp @@ -445,9 +445,9 @@ void DatabaseOrdinary::drop() void DatabaseOrdinary::alterTable( const Context & context, const String & name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const ASTModifier & storage_modifier) { diff --git a/dbms/src/Databases/DatabaseOrdinary.h b/dbms/src/Databases/DatabaseOrdinary.h index bfc197edbf8..323e012b269 100644 --- a/dbms/src/Databases/DatabaseOrdinary.h +++ b/dbms/src/Databases/DatabaseOrdinary.h @@ -44,9 +44,9 @@ public: void alterTable( const Context & context, const String & name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const ASTModifier & engine_modifier) override; diff --git a/dbms/src/Databases/IDatabase.h b/dbms/src/Databases/IDatabase.h index 6ef75e2ecf7..f1c3b90f6aa 100644 --- a/dbms/src/Databases/IDatabase.h +++ b/dbms/src/Databases/IDatabase.h @@ -113,9 +113,9 @@ public: virtual void alterTable( const Context & context, const String & name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const ASTModifier & engine_modifier) = 0; diff --git a/dbms/src/Functions/FunctionsHigherOrder.h b/dbms/src/Functions/FunctionsHigherOrder.h index 12f4ff314f2..eb6a6f447b6 100644 --- a/dbms/src/Functions/FunctionsHigherOrder.h +++ b/dbms/src/Functions/FunctionsHigherOrder.h @@ -741,7 +741,7 @@ public: /// Let's add to the block all the columns mentioned in the expression, multiplied into an array parallel to the one being processed. const ExpressionActions & expression = *column_expression->getExpression(); - const NamesAndTypes & required_columns = expression.getRequiredColumnsWithTypes(); + const NamesAndTypesList & required_columns = expression.getRequiredColumnsWithTypes(); Names argument_name_vector = column_expression->getArgumentNames(); NameSet argument_names(argument_name_vector.begin(), argument_name_vector.end()); diff --git a/dbms/src/Interpreters/Context.h b/dbms/src/Interpreters/Context.h index 52a7428ec85..33e43c03df8 100644 --- a/dbms/src/Interpreters/Context.h +++ b/dbms/src/Interpreters/Context.h @@ -6,9 +6,6 @@ #include #include #include -#include -#include -#include #include #include diff --git a/dbms/src/Interpreters/ExpressionActions.cpp b/dbms/src/Interpreters/ExpressionActions.cpp index 5f0c994363f..6f1c13ac893 100644 --- a/dbms/src/Interpreters/ExpressionActions.cpp +++ b/dbms/src/Interpreters/ExpressionActions.cpp @@ -133,7 +133,7 @@ ExpressionAction ExpressionAction::arrayJoin(const NameSet & array_joined_column return a; } -ExpressionAction ExpressionAction::ordinaryJoin(std::shared_ptr join_, const NamesAndTypes & columns_added_by_join_) +ExpressionAction ExpressionAction::ordinaryJoin(std::shared_ptr join_, const NamesAndTypesList & columns_added_by_join_) { ExpressionAction a; a.type = JOIN; @@ -521,7 +521,7 @@ std::string ExpressionAction::toString() const case JOIN: ss << "JOIN "; - for (NamesAndTypes::const_iterator it = columns_added_by_join.begin(); it != columns_added_by_join.end(); ++it) + for (NamesAndTypesList::const_iterator it = columns_added_by_join.begin(); it != columns_added_by_join.end(); ++it) { if (it != columns_added_by_join.begin()) ss << ", "; @@ -583,7 +583,7 @@ void ExpressionActions::addInput(const ColumnWithTypeAndName & column) sample_block.insert(column); } -void ExpressionActions::addInput(const NameAndType & column) +void ExpressionActions::addInput(const NameAndTypePair & column) { addInput(ColumnWithTypeAndName(nullptr, column.type, column.name)); } @@ -717,7 +717,7 @@ void ExpressionActions::executeOnTotals(Block & block) const action.executeOnTotals(block); } -std::string ExpressionActions::getSmallestColumn(const NamesAndTypes & columns) +std::string ExpressionActions::getSmallestColumn(const NamesAndTypesList & columns) { std::optional min_size; String res; @@ -758,8 +758,8 @@ void ExpressionActions::finalize(const Names & output_columns) NameSet unmodified_columns; { - NamesAndTypes sample_columns = sample_block.getNamesAndTypes(); - for (NamesAndTypes::iterator it = sample_columns.begin(); it != sample_columns.end(); ++it) + NamesAndTypesList sample_columns = sample_block.getNamesAndTypesList(); + for (NamesAndTypesList::iterator it = sample_columns.begin(); it != sample_columns.end(); ++it) unmodified_columns.insert(it->name); } @@ -856,9 +856,9 @@ void ExpressionActions::finalize(const Names & output_columns) if (final_columns.empty()) final_columns.insert(getSmallestColumn(input_columns)); - for (NamesAndTypes::iterator it = input_columns.begin(); it != input_columns.end();) + for (NamesAndTypesList::iterator it = input_columns.begin(); it != input_columns.end();) { - NamesAndTypes::iterator it0 = it; + NamesAndTypesList::iterator it0 = it; ++it; if (!needed_columns.count(it0->name)) { @@ -965,8 +965,8 @@ std::string ExpressionActions::getID() const } ss << ": {"; - NamesAndTypes output_columns = sample_block.getNamesAndTypes(); - for (NamesAndTypes::const_iterator it = output_columns.begin(); it != output_columns.end(); ++it) + NamesAndTypesList output_columns = sample_block.getNamesAndTypesList(); + for (NamesAndTypesList::const_iterator it = output_columns.begin(); it != output_columns.end(); ++it) { if (it != output_columns.begin()) ss << ", "; @@ -982,7 +982,7 @@ std::string ExpressionActions::dumpActions() const std::stringstream ss; ss << "input:\n"; - for (NamesAndTypes::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) + for (NamesAndTypesList::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) ss << it->name << " " << it->type->getName() << "\n"; ss << "\nactions:\n"; @@ -990,8 +990,8 @@ std::string ExpressionActions::dumpActions() const ss << actions[i].toString() << '\n'; ss << "\noutput:\n"; - NamesAndTypes output_columns = sample_block.getNamesAndTypes(); - for (NamesAndTypes::const_iterator it = output_columns.begin(); it != output_columns.end(); ++it) + NamesAndTypesList output_columns = sample_block.getNamesAndTypesList(); + for (NamesAndTypesList::const_iterator it = output_columns.begin(); it != output_columns.end(); ++it) ss << it->name << " " << it->type->getName() << "\n"; return ss.str(); diff --git a/dbms/src/Interpreters/ExpressionActions.h b/dbms/src/Interpreters/ExpressionActions.h index 69ef9184e41..3588aceffe6 100644 --- a/dbms/src/Interpreters/ExpressionActions.h +++ b/dbms/src/Interpreters/ExpressionActions.h @@ -78,7 +78,7 @@ public: /// For JOIN std::shared_ptr join; - NamesAndTypes columns_added_by_join; + NamesAndTypesList columns_added_by_join; /// For PROJECT. NamesWithAliases projection; @@ -93,7 +93,7 @@ public: static ExpressionAction project(const NamesWithAliases & projected_columns_); static ExpressionAction project(const Names & projected_columns_); static ExpressionAction arrayJoin(const NameSet & array_joined_columns, bool array_join_is_left, const Context & context); - static ExpressionAction ordinaryJoin(std::shared_ptr join_, const NamesAndTypes & columns_added_by_join_); + static ExpressionAction ordinaryJoin(std::shared_ptr join_, const NamesAndTypesList & columns_added_by_join_); /// Which columns necessary to perform this action. /// If this `Action` is not already added to `ExpressionActions`, the returned list may be incomplete, because `prerequisites` are not taken into account. @@ -118,7 +118,7 @@ class ExpressionActions public: using Actions = std::vector; - ExpressionActions(const NamesAndTypes & input_columns_, const Settings & settings_) + ExpressionActions(const NamesAndTypesList & input_columns_, const Settings & settings_) : input_columns(input_columns_), settings(settings_) { for (const auto & input_elem : input_columns) @@ -140,7 +140,7 @@ public: /// The name of the column must not match the names of the intermediate columns that occur when evaluating the expression. /// The expression must not have any PROJECT actions. void addInput(const ColumnWithTypeAndName & column); - void addInput(const NameAndType & column); + void addInput(const NameAndTypePair & column); void add(const ExpressionAction & action); @@ -173,12 +173,12 @@ public: Names getRequiredColumns() const { Names names; - for (NamesAndTypes::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) + for (NamesAndTypesList::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) names.push_back(it->name); return names; } - const NamesAndTypes & getRequiredColumnsWithTypes() const { return input_columns; } + const NamesAndTypesList & getRequiredColumnsWithTypes() const { return input_columns; } /// Execute the expression on the block. The block must contain all the columns returned by getRequiredColumns. void execute(Block & block) const; @@ -195,12 +195,12 @@ public: std::string dumpActions() const; - static std::string getSmallestColumn(const NamesAndTypes & columns); + static std::string getSmallestColumn(const NamesAndTypesList & columns); BlockInputStreamPtr createStreamWithNonJoinedDataIfFullOrRightJoin(size_t max_block_size) const; private: - NamesAndTypes input_columns; + NamesAndTypesList input_columns; Actions actions; Block sample_block; Settings settings; diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.cpp b/dbms/src/Interpreters/ExpressionAnalyzer.cpp index d130695b024..2bcafe01b4d 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.cpp +++ b/dbms/src/Interpreters/ExpressionAnalyzer.cpp @@ -136,7 +136,7 @@ bool functionIsInOrGlobalInOperator(const String & name) return name == "in" || name == "notIn" || name == "globalIn" || name == "globalNotIn"; } -void removeDuplicateColumns(NamesAndTypes & columns) +void removeDuplicateColumns(NamesAndTypesList & columns) { std::set names; for (auto it = columns.begin(); it != columns.end();) @@ -155,7 +155,7 @@ ExpressionAnalyzer::ExpressionAnalyzer( const ASTPtr & ast_, const Context & context_, const StoragePtr & storage_, - const NamesAndTypes & columns_, + const NamesAndTypesList & columns_, size_t subquery_depth_, bool do_global_) : ast(ast_), context(context_), settings(context.getSettings()), @@ -541,7 +541,7 @@ void ExpressionAnalyzer::analyzeAggregation() } } - NameAndType key{column_name, col.type}; + NameAndTypePair key{column_name, col.type}; /// Aggregation keys are uniqued. if (!unique_keys.count(key.name)) @@ -569,7 +569,7 @@ void ExpressionAnalyzer::analyzeAggregation() } else { - aggregated_columns = temp_actions->getSampleBlock().getNamesAndTypes(); + aggregated_columns = temp_actions->getSampleBlock().getNamesAndTypesList(); } } @@ -795,9 +795,9 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name_or_t auto interpreter = interpretSubquery(subquery_or_table_name, context, subquery_depth, {}); Block sample = interpreter->getSampleBlock(); - NamesAndTypes columns = sample.getNamesAndTypes(); + NamesAndTypesList columns = sample.getNamesAndTypesList(); - StoragePtr external_storage = StorageMemory::create(external_table_name, columns, NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}); + StoragePtr external_storage = StorageMemory::create(external_table_name, columns, NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}); external_storage->startup(); /** There are two ways to perform distributed GLOBAL subqueries. @@ -892,10 +892,10 @@ void ExpressionAnalyzer::addExternalStorage(ASTPtr & subquery_or_table_name_or_t } -NamesAndTypes::iterator ExpressionAnalyzer::findColumn(const String & name, NamesAndTypes & cols) +NamesAndTypesList::iterator ExpressionAnalyzer::findColumn(const String & name, NamesAndTypesList & cols) { return std::find_if(cols.begin(), cols.end(), - [&](const NamesAndTypes::value_type & val) { return val.name == name; }); + [&](const NamesAndTypesList::value_type & val) { return val.name == name; }); } @@ -1460,7 +1460,7 @@ void ExpressionAnalyzer::optimizeGroupBy() String unused_column_name = toString(unused_column); while (columns.end() != std::find_if(columns.begin(), columns.end(), - [&unused_column_name](const NameAndType & name_type) { return name_type.name == unused_column_name; })) + [&unused_column_name](const NameAndTypePair & name_type) { return name_type.name == unused_column_name; })) { ++unused_column; unused_column_name = toString(unused_column); @@ -1793,7 +1793,7 @@ struct ExpressionAnalyzer::ScopeStack stack.back().new_columns.insert(sample_block.getByPosition(i).name); } - void pushLevel(const NamesAndTypes & input_columns) + void pushLevel(const NamesAndTypesList & input_columns) { stack.emplace_back(); Level & prev = stack[stack.size() - 2]; @@ -1801,7 +1801,7 @@ struct ExpressionAnalyzer::ScopeStack ColumnsWithTypeAndName all_columns; NameSet new_names; - for (NamesAndTypes::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) + for (NamesAndTypesList::const_iterator it = input_columns.begin(); it != input_columns.end(); ++it) { all_columns.emplace_back(nullptr, it->type, it->name); new_names.insert(it->name); @@ -2167,7 +2167,7 @@ void ExpressionAnalyzer::getActionsImpl(const ASTPtr & ast, bool no_subqueries, const DataTypeExpression * lambda_type = typeid_cast(argument_types[i].get()); ASTFunction * lambda_args_tuple = typeid_cast(lambda->arguments->children.at(0).get()); ASTs lambda_arg_asts = lambda_args_tuple->arguments->children; - NamesAndTypes lambda_arguments; + NamesAndTypesList lambda_arguments; for (size_t j = 0; j < lambda_arg_asts.size(); ++j) { @@ -2328,7 +2328,7 @@ void ExpressionAnalyzer::assertAggregation() const throw Exception("No aggregation", ErrorCodes::LOGICAL_ERROR); } -void ExpressionAnalyzer::initChain(ExpressionActionsChain & chain, const NamesAndTypes & columns) const +void ExpressionAnalyzer::initChain(ExpressionActionsChain & chain, const NamesAndTypesList & columns) const { if (chain.steps.empty()) { @@ -2679,7 +2679,7 @@ ExpressionActionsPtr ExpressionAnalyzer::getActions(bool project_result) ExpressionActionsPtr ExpressionAnalyzer::getConstActions() { - ExpressionActionsPtr actions = std::make_shared(NamesAndTypes(), settings); + ExpressionActionsPtr actions = std::make_shared(NamesAndTypesList(), settings); getRootActions(ast, true, true, actions); @@ -2739,7 +2739,7 @@ void ExpressionAnalyzer::collectUsedColumns() NameSet required_joined_columns; getRequiredColumnsImpl(ast, available_columns, required, ignored, available_joined_columns, required_joined_columns); - for (NamesAndTypes::iterator it = columns_added_by_join.begin(); it != columns_added_by_join.end();) + for (NamesAndTypesList::iterator it = columns_added_by_join.begin(); it != columns_added_by_join.end();) { if (required_joined_columns.count(it->name)) ++it; @@ -2762,7 +2762,7 @@ void ExpressionAnalyzer::collectUsedColumns() unknown_required_columns = required; - for (NamesAndTypes::iterator it = columns.begin(); it != columns.end();) + for (NamesAndTypesList::iterator it = columns.begin(); it != columns.end();) { unknown_required_columns.erase(it->name); @@ -2789,7 +2789,7 @@ void ExpressionAnalyzer::collectUsedColumns() } } -void ExpressionAnalyzer::collectJoinedColumns(NameSet & joined_columns, NamesAndTypes & joined_columns_name_type) +void ExpressionAnalyzer::collectJoinedColumns(NameSet & joined_columns, NamesAndTypesList & joined_columns_name_type) { if (!select_query) return; diff --git a/dbms/src/Interpreters/ExpressionAnalyzer.h b/dbms/src/Interpreters/ExpressionAnalyzer.h index a7e7c94726b..cda458513cc 100644 --- a/dbms/src/Interpreters/ExpressionAnalyzer.h +++ b/dbms/src/Interpreters/ExpressionAnalyzer.h @@ -1,10 +1,5 @@ #pragma once -#include -#include -#include -#include - #include #include #include @@ -75,7 +70,7 @@ public: const ASTPtr & ast_, const Context & context_, const StoragePtr & storage_, - const NamesAndTypes & columns_, + const NamesAndTypesList & columns_, size_t subquery_depth_ = 0, bool do_global_ = false); @@ -159,16 +154,16 @@ private: /** Original columns. * First, all available columns of the table are placed here. Then (when parsing the query), unused columns are deleted. */ - NamesAndTypes columns; + NamesAndTypesList columns; /// Columns after ARRAY JOIN, JOIN, and/or aggregation. - NamesAndTypes aggregated_columns; + NamesAndTypesList aggregated_columns; /// The table from which the query is made. const StoragePtr storage; bool has_aggregation = false; - NamesAndTypes aggregation_keys; + NamesAndTypesList aggregation_keys; AggregateDescriptions aggregate_descriptions; SubqueriesForSets subqueries_for_sets; @@ -187,7 +182,7 @@ private: Names join_key_names_left; Names join_key_names_right; - NamesAndTypes columns_added_by_join; + NamesAndTypesList columns_added_by_join; using Aliases = std::unordered_map; Aliases aliases; @@ -216,8 +211,8 @@ private: void init(); - static NamesAndTypes::iterator findColumn(const String & name, NamesAndTypes & cols); - NamesAndTypes::iterator findColumn(const String & name) { return findColumn(name, columns); } + static NamesAndTypesList::iterator findColumn(const String & name, NamesAndTypesList & cols); + NamesAndTypesList::iterator findColumn(const String & name) { return findColumn(name, columns); } /** Remove all unnecessary columns from the list of all available columns of the table (`columns`). * At the same time, form a set of unknown columns (`unknown_required_columns`), @@ -227,7 +222,7 @@ private: /** Find the columns that are obtained by JOIN. */ - void collectJoinedColumns(NameSet & joined_columns, NamesAndTypes & joined_columns_name_type); + void collectJoinedColumns(NameSet & joined_columns, NamesAndTypesList & joined_columns_name_type); /** Create a dictionary of aliases. */ @@ -308,7 +303,7 @@ private: StoragePtr getTable(); /// columns - the columns that are present before the transformations begin. - void initChain(ExpressionActionsChain & chain, const NamesAndTypes & columns) const; + void initChain(ExpressionActionsChain & chain, const NamesAndTypesList & columns) const; void assertSelect() const; void assertAggregation() const; diff --git a/dbms/src/Interpreters/InterpreterCreateQuery.cpp b/dbms/src/Interpreters/InterpreterCreateQuery.cpp index 291c6d0db36..f5b4fea906f 100644 --- a/dbms/src/Interpreters/InterpreterCreateQuery.cpp +++ b/dbms/src/Interpreters/InterpreterCreateQuery.cpp @@ -161,17 +161,17 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create) } -using ColumnsAndDefaults = std::pair; +using ColumnsAndDefaults = std::pair; /// AST to the list of columns with types. Columns of Nested type are expanded into a list of real columns. static ColumnsAndDefaults parseColumns(const ASTExpressionList & column_list_ast, const Context & context) { /// list of table columns in correct order - NamesAndTypes columns{}; + NamesAndTypesList columns{}; ColumnDefaults defaults{}; /// Columns requiring type-deduction or default_expression type-check - std::vector> defaulted_columns{}; + std::vector> defaulted_columns{}; /** all default_expressions as a single expression list, * mixed with conversion-columns for each explicitly specified type */ @@ -261,12 +261,12 @@ static ColumnsAndDefaults parseColumns(const ASTExpressionList & column_list_ast } -static NamesAndTypes removeAndReturnColumns(ColumnsAndDefaults & columns_and_defaults, const ColumnDefaultType type) +static NamesAndTypesList removeAndReturnColumns(ColumnsAndDefaults & columns_and_defaults, const ColumnDefaultType type) { auto & columns = columns_and_defaults.first; auto & defaults = columns_and_defaults.second; - NamesAndTypes removed{}; + NamesAndTypesList removed{}; for (auto it = std::begin(columns); it != std::end(columns);) { @@ -284,7 +284,7 @@ static NamesAndTypes removeAndReturnColumns(ColumnsAndDefaults & columns_and_def } -ASTPtr InterpreterCreateQuery::formatColumns(const NamesAndTypes & columns) +ASTPtr InterpreterCreateQuery::formatColumns(const NamesAndTypesList & columns) { auto columns_list = std::make_shared(); @@ -307,9 +307,9 @@ ASTPtr InterpreterCreateQuery::formatColumns(const NamesAndTypes & columns) } ASTPtr InterpreterCreateQuery::formatColumns( - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults) { auto columns_list = std::make_shared(); @@ -393,7 +393,7 @@ InterpreterCreateQuery::ColumnsInfo InterpreterCreateQuery::setColumns( /// Check for duplicates std::set all_columns; - auto check_column_already_exists = [&all_columns](const NameAndType & column_name_and_type) + auto check_column_already_exists = [&all_columns](const NameAndTypePair & column_name_and_type) { if (!all_columns.emplace(column_name_and_type.name).second) throw Exception("Column " + backQuoteIfNeed(column_name_and_type.name) + " already exists", ErrorCodes::DUPLICATE_COLUMN); diff --git a/dbms/src/Interpreters/InterpreterCreateQuery.h b/dbms/src/Interpreters/InterpreterCreateQuery.h index 7847441eaef..5c4ebcbd35d 100644 --- a/dbms/src/Interpreters/InterpreterCreateQuery.h +++ b/dbms/src/Interpreters/InterpreterCreateQuery.h @@ -26,11 +26,11 @@ public: BlockIO execute() override; /// List of columns and their types in AST. - static ASTPtr formatColumns(const NamesAndTypes & columns); + static ASTPtr formatColumns(const NamesAndTypesList & columns); static ASTPtr formatColumns( - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults); void setDatabaseLoadingThreadpool(ThreadPool & thread_pool_) @@ -45,9 +45,9 @@ public: struct ColumnsInfo { - NamesAndTypes columns; - NamesAndTypes materialized_columns; - NamesAndTypes alias_columns; + NamesAndTypesList columns; + NamesAndTypesList materialized_columns; + NamesAndTypesList alias_columns; ColumnDefaults column_defaults; }; diff --git a/dbms/src/Interpreters/InterpreterDescribeQuery.cpp b/dbms/src/Interpreters/InterpreterDescribeQuery.cpp index 5ab9af46965..af61a20d6f8 100644 --- a/dbms/src/Interpreters/InterpreterDescribeQuery.cpp +++ b/dbms/src/Interpreters/InterpreterDescribeQuery.cpp @@ -57,14 +57,14 @@ BlockInputStreamPtr InterpreterDescribeQuery::executeImpl() { const ASTDescribeQuery & ast = typeid_cast(*query_ptr); - NamesAndTypes columns; + NamesAndTypesList columns; ColumnDefaults column_defaults; StoragePtr table; auto table_expression = typeid_cast(ast.table_expression.get()); if (table_expression->subquery) - columns = InterpreterSelectQuery::getSampleBlock(table_expression->subquery->children[0], context).getNamesAndTypes(); + columns = InterpreterSelectQuery::getSampleBlock(table_expression->subquery->children[0], context).getNamesAndTypesList(); else { if (table_expression->table_function) diff --git a/dbms/src/Interpreters/InterpreterInsertQuery.cpp b/dbms/src/Interpreters/InterpreterInsertQuery.cpp index 4d82b4a105a..72df1fae173 100644 --- a/dbms/src/Interpreters/InterpreterInsertQuery.cpp +++ b/dbms/src/Interpreters/InterpreterInsertQuery.cpp @@ -106,7 +106,7 @@ BlockIO InterpreterInsertQuery::execute() auto table_lock = table->lockStructure(true, __PRETTY_FUNCTION__); - NamesAndTypes required_columns = table->getColumnsList(); + NamesAndTypesList required_columns = table->getColumnsList(); /// We create a pipeline of several streams, into which we will write data. BlockOutputStreamPtr out; diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 1e3e6c415cb..3487d5cf8bd 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -143,7 +143,7 @@ void InterpreterSelectQuery::basicInit(const BlockInputStreamPtr & input) { if (table_column_names.empty()) { - table_column_names = InterpreterSelectQuery::getSampleBlock(query_table, context).getNamesAndTypes(); + table_column_names = InterpreterSelectQuery::getSampleBlock(query_table, context).getNamesAndTypesList(); } } else @@ -251,7 +251,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(const ASTPtr & query_ptr_, const InterpreterSelectQuery::InterpreterSelectQuery(const ASTPtr & query_ptr_, const Context & context_, const Names & required_column_names_, - const NamesAndTypes & table_column_names_, QueryProcessingStage::Enum to_stage_, size_t subquery_depth_, BlockInputStreamPtr input) + const NamesAndTypesList & table_column_names_, QueryProcessingStage::Enum to_stage_, size_t subquery_depth_, BlockInputStreamPtr input) : query_ptr(query_ptr_) , query(typeid_cast(*query_ptr)) , context(context_) @@ -344,7 +344,7 @@ void InterpreterSelectQuery::getDatabaseAndTableNames(String & database_name, St DataTypes InterpreterSelectQuery::getReturnTypes() { DataTypes res; - const NamesAndTypes & columns = query_analyzer->getSelectSampleBlock().getNamesAndTypes(); + const NamesAndTypesList & columns = query_analyzer->getSelectSampleBlock().getNamesAndTypesList(); for (auto & column : columns) res.push_back(column.type); diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.h b/dbms/src/Interpreters/InterpreterSelectQuery.h index 7a8f5c6ee9d..57e8c925f98 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.h +++ b/dbms/src/Interpreters/InterpreterSelectQuery.h @@ -64,7 +64,7 @@ public: const ASTPtr & query_ptr_, const Context & context_, const Names & required_column_names, - const NamesAndTypes & table_column_names_, + const NamesAndTypesList & table_column_names_, QueryProcessingStage::Enum to_stage_ = QueryProcessingStage::Complete, size_t subquery_depth_ = 0, BlockInputStreamPtr input = nullptr); @@ -176,7 +176,7 @@ private: QueryProcessingStage::Enum to_stage; size_t subquery_depth; std::unique_ptr query_analyzer; - NamesAndTypes table_column_names; + NamesAndTypesList table_column_names; /// How many streams we ask for storage to produce, and in how many threads we will do further processing. size_t max_streams = 1; diff --git a/dbms/src/Interpreters/SystemLog.h b/dbms/src/Interpreters/SystemLog.h index f5f1df5a9c0..79491521a67 100644 --- a/dbms/src/Interpreters/SystemLog.h +++ b/dbms/src/Interpreters/SystemLog.h @@ -328,7 +328,7 @@ void SystemLog::prepareTable() create->table = table_name; Block sample = LogElement::createBlock(); - create->set(create->columns, InterpreterCreateQuery::formatColumns(sample.getNamesAndTypes())); + create->set(create->columns, InterpreterCreateQuery::formatColumns(sample.getNamesAndTypesList())); ParserStorage storage_parser; ASTPtr storage_ast = parseQuery( diff --git a/dbms/src/Interpreters/evaluateConstantExpression.cpp b/dbms/src/Interpreters/evaluateConstantExpression.cpp index b4a1bd2c014..964aae94619 100644 --- a/dbms/src/Interpreters/evaluateConstantExpression.cpp +++ b/dbms/src/Interpreters/evaluateConstantExpression.cpp @@ -25,7 +25,7 @@ namespace ErrorCodes std::pair> evaluateConstantExpression(const ASTPtr & node, const Context & context) { ExpressionActionsPtr expr_for_constant_folding = ExpressionAnalyzer( - node, context, nullptr, NamesAndTypes{{ "_dummy", std::make_shared() }}).getConstActions(); + node, context, nullptr, NamesAndTypesList{{ "_dummy", std::make_shared() }}).getConstActions(); /// There must be at least one column in the block so that it knows the number of rows. Block block_with_constants{{ ColumnConst::create(ColumnUInt8::create(1, 0), 1), std::make_shared(), "_dummy" }}; diff --git a/dbms/src/Interpreters/evaluateMissingDefaults.cpp b/dbms/src/Interpreters/evaluateMissingDefaults.cpp index 3da10017983..0b9bcb5417f 100644 --- a/dbms/src/Interpreters/evaluateMissingDefaults.cpp +++ b/dbms/src/Interpreters/evaluateMissingDefaults.cpp @@ -12,7 +12,7 @@ namespace DB { void evaluateMissingDefaults(Block & block, - const NamesAndTypes & required_columns, + const NamesAndTypesList & required_columns, const ColumnDefaults & column_defaults, const Context & context) { @@ -43,7 +43,7 @@ void evaluateMissingDefaults(Block & block, Block copy_block{block}; /// evaluate default values for defaulted columns - NamesAndTypes available_columns; + NamesAndTypesList available_columns; for (size_t i = 0, size = block.columns(); i < size; ++i) available_columns.emplace_back(block.getByPosition(i).name, block.getByPosition(i).type); diff --git a/dbms/src/Interpreters/evaluateMissingDefaults.h b/dbms/src/Interpreters/evaluateMissingDefaults.h index b5fc8fe3062..a9b46d8dee5 100644 --- a/dbms/src/Interpreters/evaluateMissingDefaults.h +++ b/dbms/src/Interpreters/evaluateMissingDefaults.h @@ -9,11 +9,11 @@ namespace DB class Block; class Context; -class NamesAndTypes; +class NamesAndTypesList; struct ColumnDefault; void evaluateMissingDefaults(Block & block, - const NamesAndTypes & required_columns, + const NamesAndTypesList & required_columns, const std::unordered_map & column_defaults, const Context & context); diff --git a/dbms/src/Interpreters/tests/expression.cpp b/dbms/src/Interpreters/tests/expression.cpp index 92c5fe1e1cf..0b2ead8bd52 100644 --- a/dbms/src/Interpreters/tests/expression.cpp +++ b/dbms/src/Interpreters/tests/expression.cpp @@ -47,7 +47,7 @@ int main(int argc, char ** argv) std::cerr << std::endl; Context context = Context::createGlobal(); - NamesAndTypes columns + NamesAndTypesList columns { {"x", std::make_shared()}, {"s1", std::make_shared()}, diff --git a/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp b/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp index f4607292d42..4b2a174071c 100644 --- a/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp +++ b/dbms/src/Interpreters/tests/in_join_subqueries_preprocessor.cpp @@ -38,7 +38,7 @@ public: std::string getRemoteTableName() const { return remote_table; } std::string getTableName() const override { return ""; } - const DB::NamesAndTypes & getColumnsListImpl() const override { return names_and_types; } + const DB::NamesAndTypesList & getColumnsListImpl() const override { return names_and_types; } protected: StorageDistributedFake(const std::string & remote_database_, const std::string & remote_table_, size_t shard_count_) @@ -50,7 +50,7 @@ private: const std::string remote_database; const std::string remote_table; size_t shard_count; - DB::NamesAndTypes names_and_types; + DB::NamesAndTypesList names_and_types; }; diff --git a/dbms/src/Server/TCPHandler.cpp b/dbms/src/Server/TCPHandler.cpp index 0dbe00ba617..8aec67aa2ba 100644 --- a/dbms/src/Server/TCPHandler.cpp +++ b/dbms/src/Server/TCPHandler.cpp @@ -625,8 +625,8 @@ bool TCPHandler::receiveData() /// If such a table does not exist, create it. if (!(storage = query_context.tryGetExternalTable(external_table_name))) { - NamesAndTypes columns = block.getNamesAndTypes(); - storage = StorageMemory::create(external_table_name, columns, NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}); + NamesAndTypesList columns = block.getNamesAndTypesList(); + storage = StorageMemory::create(external_table_name, columns, NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}); storage->startup(); query_context.addExternalTable(external_table_name, storage); } diff --git a/dbms/src/Storages/AlterCommands.cpp b/dbms/src/Storages/AlterCommands.cpp index 13f97641b2f..dc1006d82ec 100644 --- a/dbms/src/Storages/AlterCommands.cpp +++ b/dbms/src/Storages/AlterCommands.cpp @@ -22,12 +22,12 @@ namespace ErrorCodes void AlterCommand::apply( - NamesAndTypes & columns, NamesAndTypes & materialized_columns, NamesAndTypes & alias_columns, + NamesAndTypesList & columns, NamesAndTypesList & materialized_columns, NamesAndTypesList & alias_columns, ColumnDefaults & column_defaults) const { if (type == ADD_COLUMN) { - const auto exists_in = [this] (const NamesAndTypes & columns) { + const auto exists_in = [this] (const NamesAndTypesList & columns) { return columns.end() != std::find_if(columns.begin(), columns.end(), std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)); }; @@ -42,7 +42,7 @@ void AlterCommand::apply( }; } - const auto add_column = [this] (NamesAndTypes & columns) + const auto add_column = [this] (NamesAndTypesList & columns) { auto insert_it = columns.end(); @@ -85,9 +85,9 @@ void AlterCommand::apply( else if (type == DROP_COLUMN) { /// look for a column in list and remove it if present, also removing corresponding entry from column_defaults - const auto remove_column = [&column_defaults, this] (NamesAndTypes & columns) { + const auto remove_column = [&column_defaults, this] (NamesAndTypesList & columns) { auto removed = false; - NamesAndTypes::iterator column_it; + NamesAndTypesList::iterator column_it; while (columns.end() != (column_it = std::find_if(columns.begin(), columns.end(), std::bind(namesEqual, std::cref(column_name), std::placeholders::_1)))) @@ -120,7 +120,7 @@ void AlterCommand::apply( materialized_columns : alias_columns; /// find column or throw exception - const auto find_column = [this] (NamesAndTypes & columns) { + const auto find_column = [this] (NamesAndTypesList & columns) { const auto it = std::find_if(columns.begin(), columns.end(), std::bind(namesEqual, std::cref(column_name), std::placeholders::_1) ); if (it == columns.end()) @@ -171,9 +171,9 @@ void AlterCommand::apply( } -void AlterCommands::apply(NamesAndTypes & columns, - NamesAndTypes & materialized_columns, - NamesAndTypes & alias_columns, +void AlterCommands::apply(NamesAndTypesList & columns, + NamesAndTypesList & materialized_columns, + NamesAndTypesList & alias_columns, ColumnDefaults & column_defaults) const { auto new_columns = columns; @@ -196,7 +196,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) columns.insert(std::end(columns), std::begin(table->alias_columns), std::end(table->alias_columns)); auto defaults = table->column_defaults; - std::vector> defaulted_columns{}; + std::vector> defaulted_columns{}; auto default_expr_list = std::make_shared(); default_expr_list->children.reserve(defaults.size()); @@ -248,7 +248,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) default_expr_list->children.emplace_back(setAlias(command.default_expression->clone(), tmp_column_name)); - defaulted_columns.emplace_back(NameAndType{column_name, command.data_type}, &command); + defaulted_columns.emplace_back(NameAndTypePair{column_name, command.data_type}, &command); } else { @@ -256,7 +256,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) default_expr_list->children.emplace_back( setAlias(command.default_expression->clone(), column_name)); - defaulted_columns.emplace_back(NameAndType{column_name, nullptr}, &command); + defaulted_columns.emplace_back(NameAndTypePair{column_name, nullptr}, &command); } } } @@ -289,7 +289,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) for (const auto & col_def : defaults) { const auto & column_name = col_def.first; - const auto column_it = std::find_if(columns.begin(), columns.end(), [&] (const NameAndType & name_type) + const auto column_it = std::find_if(columns.begin(), columns.end(), [&] (const NameAndTypePair & name_type) { return AlterCommand::namesEqual(column_name, name_type); }); const auto tmp_column_name = column_name + "_tmp"; @@ -302,7 +302,7 @@ void AlterCommands::validate(IStorage * table, const Context & context) default_expr_list->children.emplace_back(setAlias(col_def.second.expression->clone(), tmp_column_name)); - defaulted_columns.emplace_back(NameAndType{column_name, column_type_ptr}, nullptr); + defaulted_columns.emplace_back(NameAndTypePair{column_name, column_type_ptr}, nullptr); } const auto actions = ExpressionAnalyzer{default_expr_list, context, {}, columns}.getActions(true); diff --git a/dbms/src/Storages/AlterCommands.h b/dbms/src/Storages/AlterCommands.h index b46ceae0b4d..543106254e6 100644 --- a/dbms/src/Storages/AlterCommands.h +++ b/dbms/src/Storages/AlterCommands.h @@ -37,15 +37,15 @@ struct AlterCommand ASTPtr primary_key; /// the names are the same if they match the whole name or name_without_dot matches the part of the name up to the dot - static bool namesEqual(const String & name_without_dot, const DB::NameAndType & name_type) + static bool namesEqual(const String & name_without_dot, const DB::NameAndTypePair & name_type) { String name_with_dot = name_without_dot + "."; return (name_with_dot == name_type.name.substr(0, name_without_dot.length() + 1) || name_without_dot == name_type.name); } - void apply(NamesAndTypes & columns, - NamesAndTypes & materialized_columns, - NamesAndTypes & alias_columns, + void apply(NamesAndTypesList & columns, + NamesAndTypesList & materialized_columns, + NamesAndTypesList & alias_columns, ColumnDefaults & column_defaults) const; AlterCommand() = default; @@ -63,9 +63,9 @@ class Context; class AlterCommands : public std::vector { public: - void apply(NamesAndTypes & columns, - NamesAndTypes & materialized_columns, - NamesAndTypes & alias_columns, + void apply(NamesAndTypesList & columns, + NamesAndTypesList & materialized_columns, + NamesAndTypesList & alias_columns, ColumnDefaults & column_defaults) const; void validate(IStorage * table, const Context & context); diff --git a/dbms/src/Storages/ColumnsDescription.cpp b/dbms/src/Storages/ColumnsDescription.cpp index d921e7e5c16..c0bfabea727 100644 --- a/dbms/src/Storages/ColumnsDescription.cpp +++ b/dbms/src/Storages/ColumnsDescription.cpp @@ -29,7 +29,7 @@ String ColumnsDescription::toString() const writeText(columns.size() + materialized.size() + alias.size(), buf); writeString(" columns:\n", buf); - const auto write_columns = [this, &buf] (const NamesAndTypes & columns) + const auto write_columns = [this, &buf] (const NamesAndTypesList & columns) { for (const auto & column : columns) { diff --git a/dbms/src/Storages/ColumnsDescription.h b/dbms/src/Storages/ColumnsDescription.h index dded2db3c9a..cce6232d33b 100644 --- a/dbms/src/Storages/ColumnsDescription.h +++ b/dbms/src/Storages/ColumnsDescription.h @@ -14,9 +14,9 @@ struct ColumnsDescription template using by_value_or_cref = std::conditional_t; - by_value_or_cref columns; - by_value_or_cref materialized; - by_value_or_cref alias; + by_value_or_cref columns; + by_value_or_cref materialized; + by_value_or_cref alias; by_value_or_cref defaults; String toString() const; diff --git a/dbms/src/Storages/ITableDeclaration.cpp b/dbms/src/Storages/ITableDeclaration.cpp index 883fca48682..bf268062406 100644 --- a/dbms/src/Storages/ITableDeclaration.cpp +++ b/dbms/src/Storages/ITableDeclaration.cpp @@ -24,9 +24,9 @@ namespace ErrorCodes } -NamesAndTypes ITableDeclaration::getColumnsList() const +NamesAndTypesList ITableDeclaration::getColumnsList() const { - return ext::collection_cast(getColumnsListRange()); + return ext::collection_cast(getColumnsListRange()); } @@ -51,7 +51,7 @@ Names ITableDeclaration::getColumnNamesList() const } -NameAndType ITableDeclaration::getRealColumn(const String & column_name) const +NameAndTypePair ITableDeclaration::getRealColumn(const String & column_name) const { for (auto & it : getColumnsListRange()) if (it.name == column_name) @@ -59,7 +59,7 @@ NameAndType ITableDeclaration::getRealColumn(const String & column_name) const throw Exception("There is no column " + column_name + " in table.", ErrorCodes::NO_SUCH_COLUMN_IN_TABLE); } -NameAndType ITableDeclaration::getMaterializedColumn(const String & column_name) const +NameAndTypePair ITableDeclaration::getMaterializedColumn(const String & column_name) const { for (auto & column : materialized_columns) if (column.name == column_name) @@ -82,7 +82,7 @@ bool ITableDeclaration::hasColumn(const String & column_name) const return hasRealColumn(column_name); /// By default, we assume that there are no virtual columns in the storage. } -NameAndType ITableDeclaration::getColumn(const String & column_name) const +NameAndTypePair ITableDeclaration::getColumn(const String & column_name) const { return getRealColumn(column_name); /// By default, we assume that there are no virtual columns in the storage. } @@ -120,10 +120,10 @@ Block ITableDeclaration::getSampleBlockNonMaterialized() const } -static std::string listOfColumns(const NamesAndTypes & available_columns) +static std::string listOfColumns(const NamesAndTypesList & available_columns) { std::stringstream s; - for (NamesAndTypes::const_iterator it = available_columns.begin(); it != available_columns.end(); ++it) + for (NamesAndTypesList::const_iterator it = available_columns.begin(); it != available_columns.end(); ++it) { if (it != available_columns.begin()) s << ", "; @@ -140,7 +140,7 @@ static NamesAndTypesMap & getColumnsMapImpl(NamesAndTypesMap & res) { return res template static NamesAndTypesMap & getColumnsMapImpl(NamesAndTypesMap & res, const Arg & arg, const Args &... args) { - static_assert(std::is_same_v, "getColumnsMap requires arguments of type NamesAndTypes"); + static_assert(std::is_same_v, "getColumnsMap requires arguments of type NamesAndTypesList"); for (const auto & column : arg) res.insert({column.name, column.type.get()}); @@ -160,7 +160,7 @@ static NamesAndTypesMap getColumnsMap(const Args &... args) void ITableDeclaration::check(const Names & column_names) const { - const NamesAndTypes & available_columns = getColumnsList(); + const NamesAndTypesList & available_columns = getColumnsList(); if (column_names.empty()) throw Exception("Empty list of columns queried. There are columns: " + listOfColumns(available_columns), @@ -186,16 +186,16 @@ void ITableDeclaration::check(const Names & column_names) const } -void ITableDeclaration::check(const NamesAndTypes & columns) const +void ITableDeclaration::check(const NamesAndTypesList & columns) const { - const NamesAndTypes & available_columns = getColumnsList(); + const NamesAndTypesList & available_columns = getColumnsList(); const auto columns_map = getColumnsMap(available_columns); using UniqueStrings = google::dense_hash_set; UniqueStrings unique_names; unique_names.set_empty_key(StringRef()); - for (const NameAndType & column : columns) + for (const NameAndTypePair & column : columns) { NamesAndTypesMap::const_iterator it = columns_map.find(column.name); if (columns_map.end() == it) @@ -214,9 +214,9 @@ void ITableDeclaration::check(const NamesAndTypes & columns) const } -void ITableDeclaration::check(const NamesAndTypes & columns, const Names & column_names) const +void ITableDeclaration::check(const NamesAndTypesList & columns, const Names & column_names) const { - const NamesAndTypes & available_columns = getColumnsList(); + const NamesAndTypesList & available_columns = getColumnsList(); const auto available_columns_map = getColumnsMap(available_columns); const NamesAndTypesMap & provided_columns_map = getColumnsMap(columns); @@ -253,7 +253,7 @@ void ITableDeclaration::check(const NamesAndTypes & columns, const Names & colum void ITableDeclaration::check(const Block & block, bool need_all) const { - const NamesAndTypes & available_columns = getColumnsList(); + const NamesAndTypesList & available_columns = getColumnsList(); const auto columns_map = getColumnsMap(available_columns); using NameSet = std::unordered_set; @@ -281,7 +281,7 @@ void ITableDeclaration::check(const Block & block, bool need_all) const if (need_all && names_in_block.size() < columns_map.size()) { - for (NamesAndTypes::const_iterator it = available_columns.begin(); it != available_columns.end(); ++it) + for (NamesAndTypesList::const_iterator it = available_columns.begin(); it != available_columns.end(); ++it) { if (!names_in_block.count(it->name)) throw Exception("Expected column " + it->name, ErrorCodes::NOT_FOUND_COLUMN_IN_BLOCK); diff --git a/dbms/src/Storages/ITableDeclaration.h b/dbms/src/Storages/ITableDeclaration.h index 8da91a307d5..4861a36205f 100644 --- a/dbms/src/Storages/ITableDeclaration.h +++ b/dbms/src/Storages/ITableDeclaration.h @@ -27,8 +27,8 @@ public: /** Get a list of names and table column types, only non-virtual. */ - NamesAndTypes getColumnsList() const; - const NamesAndTypes & getColumnsListNonMaterialized() const { return getColumnsListImpl(); } + NamesAndTypesList getColumnsList() const; + const NamesAndTypesList & getColumnsListNonMaterialized() const { return getColumnsListImpl(); } /** Get a list of column table names, only non-virtual. */ @@ -36,18 +36,18 @@ public: /** Get a description of the real (non-virtual) column by its name. */ - virtual NameAndType getRealColumn(const String & column_name) const; + virtual NameAndTypePair getRealColumn(const String & column_name) const; /** Is there a real (non-virtual) column with that name. */ virtual bool hasRealColumn(const String & column_name) const; - NameAndType getMaterializedColumn(const String & column_name) const; + NameAndTypePair getMaterializedColumn(const String & column_name) const; bool hasMaterializedColumn(const String & column_name) const; /** Get a description of any column by its name. */ - virtual NameAndType getColumn(const String & column_name) const; + virtual NameAndTypePair getColumn(const String & column_name) const; /** Is there a column with that name. */ @@ -67,11 +67,11 @@ public: /** Check that all the requested names are in the table and have the correct types. */ - void check(const NamesAndTypes & columns) const; + void check(const NamesAndTypesList & columns) const; /** Check that all names from the intersection of `names` and `columns` are in the table and have the same types. */ - void check(const NamesAndTypes & columns, const Names & column_names) const; + void check(const NamesAndTypesList & columns, const Names & column_names) const; /** Check that the data block for the record contains all the columns of the table with the correct types, * contains only the columns of the table, and all the columns are different. @@ -84,22 +84,22 @@ public: ITableDeclaration() = default; ITableDeclaration( - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults) : materialized_columns{materialized_columns}, alias_columns{alias_columns}, column_defaults{column_defaults} {} - NamesAndTypes materialized_columns{}; - NamesAndTypes alias_columns{}; + NamesAndTypesList materialized_columns{}; + NamesAndTypesList alias_columns{}; ColumnDefaults column_defaults{}; private: - virtual const NamesAndTypes & getColumnsListImpl() const = 0; + virtual const NamesAndTypesList & getColumnsListImpl() const = 0; - using ColumnsListRange = boost::range::joined_range; + using ColumnsListRange = boost::range::joined_range; /// Returns a lazily joined range of table's ordinary and materialized columns, without unnecessary copying ColumnsListRange getColumnsListRange() const; }; diff --git a/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.cpp b/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.cpp index a529a0bcc9e..7b93c1fd181 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.cpp @@ -67,7 +67,7 @@ String MergeTreeBlockInputStream::getID() const std::stringstream res; res << "MergeTree(" << path << ", columns"; - for (const NameAndType & column : columns) + for (const NameAndTypePair & column : columns) res << ", " << column.name; if (prewhere_actions) diff --git a/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.h b/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.h index 33e47749de1..6eb9c2e8577 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.h +++ b/dbms/src/Storages/MergeTree/MergeTreeBlockInputStream.h @@ -52,8 +52,8 @@ private: /// Used by Task Names ordered_names; NameSet column_name_set; - NamesAndTypes columns; - NamesAndTypes pre_columns; + NamesAndTypesList columns; + NamesAndTypesList pre_columns; /// Data part will not be removed if the pointer owns it MergeTreeData::DataPartPtr data_part; diff --git a/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp b/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp index ed5708b8b8f..f25aa737e06 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp @@ -68,8 +68,8 @@ NameSet injectRequiredColumns(const MergeTreeData & storage, const MergeTreeData MergeTreeReadTask::MergeTreeReadTask( const MergeTreeData::DataPartPtr & data_part, const MarkRanges & mark_ranges, const size_t part_index_in_query, - const Names & ordered_names, const NameSet & column_name_set, const NamesAndTypes & columns, - const NamesAndTypes & pre_columns, const bool remove_prewhere_column, const bool should_reorder, + const Names & ordered_names, const NameSet & column_name_set, const NamesAndTypesList & columns, + const NamesAndTypesList & pre_columns, const bool remove_prewhere_column, const bool should_reorder, MergeTreeBlockSizePredictorPtr && size_predictor) : data_part{data_part}, mark_ranges{mark_ranges}, part_index_in_query{part_index_in_query}, ordered_names{ordered_names}, column_name_set{column_name_set}, columns{columns}, pre_columns{pre_columns}, diff --git a/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.h b/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.h index df6792cf875..b694b4535da 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.h +++ b/dbms/src/Storages/MergeTree/MergeTreeBlockReadUtils.h @@ -37,9 +37,9 @@ struct MergeTreeReadTask /// used to determine whether column should be filtered during PREWHERE or WHERE const NameSet & column_name_set; /// column names to read during WHERE - const NamesAndTypes & columns; + const NamesAndTypesList & columns; /// column names to read during PREWHERE - const NamesAndTypes & pre_columns; + const NamesAndTypesList & pre_columns; /// should PREWHERE column be returned to requesting side? const bool remove_prewhere_column; /// resulting block may require reordering in accordance with `ordered_names` @@ -56,8 +56,8 @@ struct MergeTreeReadTask MergeTreeReadTask( const MergeTreeData::DataPartPtr & data_part, const MarkRanges & mark_ranges, const size_t part_index_in_query, - const Names & ordered_names, const NameSet & column_name_set, const NamesAndTypes & columns, - const NamesAndTypes & pre_columns, const bool remove_prewhere_column, const bool should_reorder, + const Names & ordered_names, const NameSet & column_name_set, const NamesAndTypesList & columns, + const NamesAndTypesList & pre_columns, const bool remove_prewhere_column, const bool should_reorder, MergeTreeBlockSizePredictorPtr && size_predictor); virtual ~MergeTreeReadTask(); diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.cpp b/dbms/src/Storages/MergeTree/MergeTreeData.cpp index f2b5b465b0b..84278e746c7 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeData.cpp @@ -78,9 +78,9 @@ namespace ErrorCodes MergeTreeData::MergeTreeData( const String & database_, const String & table_, - const String & full_path_, const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const String & full_path_, const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, const ASTPtr & primary_expr_ast_, @@ -238,9 +238,9 @@ void MergeTreeData::initPartitionKey() } /// Add all columns used in the partition key to the min-max index. - const NamesAndTypes & minmax_idx_columns_with_types = partition_expr->getRequiredColumnsWithTypes(); + const NamesAndTypesList & minmax_idx_columns_with_types = partition_expr->getRequiredColumnsWithTypes(); minmax_idx_expr = std::make_shared(minmax_idx_columns_with_types, context.getSettingsRef()); - for (const NameAndType & column : minmax_idx_columns_with_types) + for (const NameAndTypePair & column : minmax_idx_columns_with_types) { minmax_idx_columns.emplace_back(column.name); minmax_idx_column_types.emplace_back(column.type); @@ -268,7 +268,7 @@ void MergeTreeData::initPartitionKey() } -void MergeTreeData::MergingParams::check(const NamesAndTypes & columns) const +void MergeTreeData::MergingParams::check(const NamesAndTypesList & columns) const { /// Check that if the sign column is needed, it exists and is of type Int8. if (mode == MergingParams::Collapsing) @@ -300,7 +300,7 @@ void MergeTreeData::MergingParams::check(const NamesAndTypes & columns) const for (const auto & column_to_sum : columns_to_sum) if (columns.end() == std::find_if(columns.begin(), columns.end(), - [&](const NameAndType & name_and_type) { return column_to_sum == Nested::extractTableName(name_and_type.name); })) + [&](const NameAndTypePair & name_and_type) { return column_to_sum == Nested::extractTableName(name_and_type.name); })) throw Exception("Column " + column_to_sum + " listed in columns to sum does not exist in table declaration."); } @@ -842,7 +842,7 @@ void MergeTreeData::checkAlter(const AlterCommands & commands) createConvertExpression(nullptr, getColumnsList(), new_columns, unused_expression, unused_map, unused_bool); } -void MergeTreeData::createConvertExpression(const DataPartPtr & part, const NamesAndTypes & old_columns, const NamesAndTypes & new_columns, +void MergeTreeData::createConvertExpression(const DataPartPtr & part, const NamesAndTypesList & old_columns, const NamesAndTypesList & new_columns, ExpressionActionsPtr & out_expression, NameToNameMap & out_rename_map, bool & out_force_update_metadata) const { out_expression = nullptr; @@ -851,7 +851,7 @@ void MergeTreeData::createConvertExpression(const DataPartPtr & part, const Name using NameToType = std::map; NameToType new_types; - for (const NameAndType & column : new_columns) + for (const NameAndTypePair & column : new_columns) new_types.emplace(column.name, column.type.get()); /// For every column that need to be converted: source column name, column name of calculated expression for conversion. @@ -859,7 +859,7 @@ void MergeTreeData::createConvertExpression(const DataPartPtr & part, const Name /// Collect counts for shared streams of different columns. As an example, Nested columns have shared stream with array sizes. std::map stream_counts; - for (const NameAndType & column : old_columns) + for (const NameAndTypePair & column : old_columns) { column.type->enumerateStreams([&](const IDataType::SubstreamPath & substream_path) { @@ -867,7 +867,7 @@ void MergeTreeData::createConvertExpression(const DataPartPtr & part, const Name }, {}); } - for (const NameAndType & column : old_columns) + for (const NameAndTypePair & column : old_columns) { if (!new_types.count(column.name)) { @@ -904,7 +904,7 @@ void MergeTreeData::createConvertExpression(const DataPartPtr & part, const Name /// Need to modify column type. if (!out_expression) - out_expression = std::make_shared(NamesAndTypes(), context.getSettingsRef()); + out_expression = std::make_shared(NamesAndTypesList(), context.getSettingsRef()); out_expression->addInput(ColumnWithTypeAndName(nullptr, column.type, column.name)); @@ -983,7 +983,7 @@ void MergeTreeData::createConvertExpression(const DataPartPtr & part, const Name MergeTreeData::AlterDataPartTransactionPtr MergeTreeData::alterDataPart( const DataPartPtr & part, - const NamesAndTypes & new_columns, + const NamesAndTypesList & new_columns, const ASTPtr & new_primary_key, bool skip_sanity_checks) { diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.h b/dbms/src/Storages/MergeTree/MergeTreeData.h index a72b7e18617..7b6959d476a 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.h +++ b/dbms/src/Storages/MergeTree/MergeTreeData.h @@ -203,7 +203,7 @@ public: ~AlterDataPartTransaction(); /// Review the changes before the commit. - const NamesAndTypes & getNewColumns() const { return new_columns; } + const NamesAndTypesList & getNewColumns() const { return new_columns; } const DataPart::Checksums & getNewChecksums() const { return new_checksums; } private: @@ -221,7 +221,7 @@ public: std::unique_lock alter_lock; DataPart::Checksums new_checksums; - NamesAndTypes new_columns; + NamesAndTypesList new_columns; /// If the value is an empty string, the file is not temporary, and it must be deleted. NameToNameMap rename_map; }; @@ -259,7 +259,7 @@ public: Graphite::Params graphite_params; /// Check that needed columns are present and have correct types. - void check(const NamesAndTypes & columns) const; + void check(const NamesAndTypesList & columns) const; String getModeName() const; }; @@ -274,9 +274,9 @@ public: /// require_part_metadata - should checksums.txt and columns.txt exist in the part directory. /// attach - whether the existing table is attached or the new table is created. MergeTreeData(const String & database_, const String & table_, - const String & full_path_, const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const String & full_path_, const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, const ASTPtr & primary_expr_ast_, @@ -305,16 +305,16 @@ public: Int64 getMaxDataPartIndex(); - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } - NameAndType getColumn(const String & column_name) const override + NameAndTypePair getColumn(const String & column_name) const override { if (column_name == "_part") - return NameAndType("_part", std::make_shared()); + return NameAndTypePair("_part", std::make_shared()); if (column_name == "_part_index") - return NameAndType("_part_index", std::make_shared()); + return NameAndTypePair("_part_index", std::make_shared()); if (column_name == "_sample_factor") - return NameAndType("_sample_factor", std::make_shared()); + return NameAndTypePair("_sample_factor", std::make_shared()); return ITableDeclaration::getColumn(column_name); } @@ -424,12 +424,12 @@ public: /// If no data transformations are necessary, returns nullptr. AlterDataPartTransactionPtr alterDataPart( const DataPartPtr & part, - const NamesAndTypes & new_columns, + const NamesAndTypesList & new_columns, const ASTPtr & new_primary_key, bool skip_sanity_checks); /// Must be called with locked lockStructureForAlter(). - void setColumnsList(const NamesAndTypes & new_columns) { columns = new_columns; } + void setColumnsList(const NamesAndTypesList & new_columns) { columns = new_columns; } /// Should be called if part data is suspected to be corrupted. void reportBrokenPart(const String & name) @@ -548,7 +548,7 @@ private: String table_name; String full_path; - NamesAndTypes columns; + NamesAndTypesList columns; /// Current column sizes in compressed and uncompressed form. ColumnSizes column_sizes; @@ -651,7 +651,7 @@ private: /// for transformation-free changing of Enum values list). /// Files to be deleted are mapped to an empty string in out_rename_map. /// If part == nullptr, just checks that all type conversions are possible. - void createConvertExpression(const DataPartPtr & part, const NamesAndTypes & old_columns, const NamesAndTypes & new_columns, + void createConvertExpression(const DataPartPtr & part, const NamesAndTypesList & old_columns, const NamesAndTypesList & new_columns, ExpressionActionsPtr & out_expression, NameToNameMap & out_rename_map, bool & out_force_update_metadata) const; /// Calculates column sizes in compressed form for the current state of data_parts. Call with data_parts mutex locked. diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp index cb289f5215f..004b104dc0c 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.cpp @@ -302,10 +302,10 @@ MergeTreeData::DataPartsVector MergeTreeDataMerger::selectAllPartsFromPartition( /// PK columns are sorted and merged, ordinary columns are gathered using info from merge step -static void extractMergingAndGatheringColumns(const NamesAndTypes & all_columns, ExpressionActionsPtr primary_key_expressions, +static void extractMergingAndGatheringColumns(const NamesAndTypesList & all_columns, ExpressionActionsPtr primary_key_expressions, const MergeTreeData::MergingParams & merging_params, - NamesAndTypes & gathering_columns, Names & gathering_column_names, - NamesAndTypes & merging_columns, Names & merging_column_names + NamesAndTypesList & gathering_columns, Names & gathering_column_names, + NamesAndTypesList & merging_columns, Names & merging_column_names ) { Names key_columns_dup = primary_key_expressions->getRequiredColumns(); @@ -505,10 +505,10 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMerger::mergePartsToTemporaryPart part->accumulateColumnSizes(merged_column_to_size); Names all_column_names = data.getColumnNamesList(); - NamesAndTypes all_columns = data.getColumnsList(); + NamesAndTypesList all_columns = data.getColumnsList(); const SortDescription sort_desc = data.getSortDescription(); - NamesAndTypes gathering_columns, merging_columns; + NamesAndTypesList gathering_columns, merging_columns; Names gathering_column_names, merging_column_names; extractMergingAndGatheringColumns(all_columns, data.getPrimaryExpression(), data.merging_params, gathering_columns, gathering_column_names, merging_columns, merging_column_names); @@ -762,7 +762,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMerger::mergePartsToTemporaryPart MergeTreeDataMerger::MergeAlgorithm MergeTreeDataMerger::chooseMergeAlgorithm( const MergeTreeData & data, const MergeTreeData::DataPartsVector & parts, size_t sum_rows_upper_bound, - const NamesAndTypes & gathering_columns, bool deduplicate) const + const NamesAndTypesList & gathering_columns, bool deduplicate) const { if (deduplicate) return MergeAlgorithm::Horizontal; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.h b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.h index 60446c2e960..e2ad5dc23a4 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMerger.h +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMerger.h @@ -121,7 +121,7 @@ private: MergeAlgorithm chooseMergeAlgorithm( const MergeTreeData & data, const MergeTreeData::DataPartsVector & parts, - size_t rows_upper_bound, const NamesAndTypes & gathering_columns, bool deduplicate) const; + size_t rows_upper_bound, const NamesAndTypesList & gathering_columns, bool deduplicate) const; private: MergeTreeData & data; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp index 7b748bb7b12..95485da3ec3 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp @@ -722,7 +722,7 @@ void MergeTreeDataPart::loadRowsCount() { size_t rows_approx = storage.index_granularity * marks_count; - for (const NameAndType & column : columns) + for (const NameAndTypePair & column : columns) { ColumnPtr column_col = column.type->createColumn(); const auto checksum = tryGetBinChecksum(column.name); @@ -758,7 +758,7 @@ void MergeTreeDataPart::accumulateColumnSizes(ColumnToSize & column_to_size) con { std::shared_lock part_lock(columns_lock); - for (const NameAndType & name_type : storage.columns) + for (const NameAndTypePair & name_type : storage.columns) { name_type.type->enumerateStreams([&](const IDataType::SubstreamPath & substream_path) { @@ -778,7 +778,7 @@ void MergeTreeDataPart::loadColumns(bool require) throw Exception("No columns.txt in part " + name, ErrorCodes::NO_FILE_IN_DATA_PART); /// If there is no file with a list of columns, write it down. - for (const NameAndType & column : storage.getColumnsList()) + for (const NameAndTypePair & column : storage.getColumnsList()) if (Poco::File(getFullPath() + escapeForFileName(column.name) + ".bin").exists()) columns.push_back(column); @@ -809,7 +809,7 @@ void MergeTreeDataPart::checkConsistency(bool require_part_metadata) if (require_part_metadata) { - for (const NameAndType & name_type : columns) + for (const NameAndTypePair & name_type : columns) { name_type.type->enumerateStreams([&](const IDataType::SubstreamPath & substream_path) { @@ -871,7 +871,7 @@ void MergeTreeDataPart::checkConsistency(bool require_part_metadata) /// Check that all marks are nonempty and have the same size. std::optional marks_size; - for (const NameAndType & name_type : columns) + for (const NameAndTypePair & name_type : columns) { name_type.type->enumerateStreams([&](const IDataType::SubstreamPath & substream_path) { diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataPart.h b/dbms/src/Storages/MergeTree/MergeTreeDataPart.h index ebe162ab2e4..9ec9cba56e6 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataPart.h +++ b/dbms/src/Storages/MergeTree/MergeTreeDataPart.h @@ -248,7 +248,7 @@ struct MergeTreeDataPart Checksums checksums; /// Columns description. - NamesAndTypes columns; + NamesAndTypesList columns; using ColumnToSize = std::map; diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 9c95469ef44..1766f604fed 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -174,9 +174,9 @@ BlockInputStreams MergeTreeDataSelectExecutor::read( } } - NamesAndTypes available_real_columns = data.getColumnsList(); + NamesAndTypesList available_real_columns = data.getColumnsList(); - NamesAndTypes available_real_and_virtual_columns = available_real_columns; + NamesAndTypesList available_real_and_virtual_columns = available_real_columns; for (const auto & name : virt_column_names) available_real_and_virtual_columns.emplace_back(data.getColumn(name)); diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataWriter.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataWriter.cpp index f7a2678cbd0..4781a005d5a 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataWriter.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataWriter.cpp @@ -198,7 +198,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataWriter::writeTempPart(BlockWithPa /// either default lz4 or compression method with zero thresholds on absolute and relative part size. auto compression_settings = data.context.chooseCompressionSettings(0, 0); - NamesAndTypes columns = data.getColumnsList().filter(block.getNames()); + NamesAndTypesList columns = data.getColumnsList().filter(block.getNames()); MergedBlockOutputStream out(data, new_data_part->getFullPath(), columns, compression_settings); out.writePrefix(); diff --git a/dbms/src/Storages/MergeTree/MergeTreeReadPool.h b/dbms/src/Storages/MergeTree/MergeTreeReadPool.h index a745e0d0b86..e93a248bab1 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeReadPool.h +++ b/dbms/src/Storages/MergeTree/MergeTreeReadPool.h @@ -94,8 +94,8 @@ private: bool do_not_steal_tasks; bool predict_block_size_bytes; std::vector per_part_column_name_set; - std::vector per_part_columns; - std::vector per_part_pre_columns; + std::vector per_part_columns; + std::vector per_part_pre_columns; /// @todo actually all of these values are either true or false for the whole query, thus no vector required std::vector per_part_remove_prewhere_column; std::vector per_part_should_reorder; diff --git a/dbms/src/Storages/MergeTree/MergeTreeReader.cpp b/dbms/src/Storages/MergeTree/MergeTreeReader.cpp index 9c3b2d600ae..4ae50b00b2e 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeReader.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeReader.cpp @@ -34,7 +34,7 @@ MergeTreeReader::~MergeTreeReader() = default; MergeTreeReader::MergeTreeReader(const String & path, - const MergeTreeData::DataPartPtr & data_part, const NamesAndTypes & columns, + const MergeTreeData::DataPartPtr & data_part, const NamesAndTypesList & columns, UncompressedCache * uncompressed_cache, MarkCache * mark_cache, bool save_marks_in_cache, MergeTreeData & storage, const MarkRanges & all_mark_ranges, size_t aio_threshold, size_t max_read_buffer_size, const ValueSizeMap & avg_value_size_hints, @@ -49,7 +49,7 @@ MergeTreeReader::MergeTreeReader(const String & path, if (!Poco::File(path).exists()) throw Exception("Part " + path + " is missing", ErrorCodes::NOT_FOUND_EXPECTED_DATA_PART); - for (const NameAndType & column : columns) + for (const NameAndTypePair & column : columns) addStreams(column.name, *column.type, all_mark_ranges, profile_callback, clock_type); } catch (...) @@ -82,7 +82,7 @@ size_t MergeTreeReader::readRows(size_t from_mark, bool continue_reading, size_t /// check that the offsets column has been already read. OffsetColumns offset_columns; - for (const NameAndType & it : columns) + for (const NameAndTypePair & it : columns) { /// The column is already present in the block so we will append the values to the end. bool append = res.has(it.name); diff --git a/dbms/src/Storages/MergeTree/MergeTreeReader.h b/dbms/src/Storages/MergeTree/MergeTreeReader.h index 9d3daf429db..6f4c1f60dc2 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeReader.h +++ b/dbms/src/Storages/MergeTree/MergeTreeReader.h @@ -24,7 +24,7 @@ public: using ValueSizeMap = std::map; MergeTreeReader(const String & path, /// Path to the directory containing the part - const MergeTreeData::DataPartPtr & data_part, const NamesAndTypes & columns, + const MergeTreeData::DataPartPtr & data_part, const NamesAndTypesList & columns, UncompressedCache * uncompressed_cache, MarkCache * mark_cache, bool save_marks_in_cache, @@ -93,7 +93,7 @@ private: FileStreams streams; /// Columns that are read. - NamesAndTypes columns; + NamesAndTypesList columns; UncompressedCache * uncompressed_cache; MarkCache * mark_cache; diff --git a/dbms/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp b/dbms/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp index e15d4cf2f2d..137f88bf3fd 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp @@ -42,7 +42,7 @@ MergeTreeWhereOptimizer::MergeTreeWhereOptimizer( : primary_key_columns{ext::map(data.getSortDescription(), [] (const SortColumnDescription & col) { return col.column_name; })}, table_columns{ext::map(data.getColumnsList(), - [] (const NameAndType & col) { return col.name; })}, + [] (const NameAndTypePair & col) { return col.name; })}, block_with_constants{PKCondition::getBlockWithConstants(query_info.query, context, data.getColumnsList())}, prepared_sets(query_info.sets), log{log} diff --git a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp index 18c14c2b68a..1b18edbf4a5 100644 --- a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp +++ b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.cpp @@ -215,7 +215,7 @@ void IMergedBlockOutputStream::ColumnStream::addToChecksums(MergeTreeData::DataP MergedBlockOutputStream::MergedBlockOutputStream( MergeTreeData & storage_, String part_path_, - const NamesAndTypes & columns_list_, + const NamesAndTypesList & columns_list_, CompressionSettings compression_settings) : IMergedBlockOutputStream( storage_, storage_.context.getSettings().min_compress_block_size, @@ -231,7 +231,7 @@ MergedBlockOutputStream::MergedBlockOutputStream( MergedBlockOutputStream::MergedBlockOutputStream( MergeTreeData & storage_, String part_path_, - const NamesAndTypes & columns_list_, + const NamesAndTypesList & columns_list_, CompressionSettings compression_settings, const MergeTreeData::DataPart::ColumnToSize & merged_column_to_size_, size_t aio_threshold_) @@ -281,7 +281,7 @@ void MergedBlockOutputStream::writeSuffix() void MergedBlockOutputStream::writeSuffixAndFinalizePart( MergeTreeData::MutableDataPartPtr & new_part, - const NamesAndTypes * total_column_list, + const NamesAndTypesList * total_column_list, MergeTreeData::DataPart::Checksums * additional_column_checksums) { if (!total_column_list) diff --git a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h index 668a8f55794..60196c3ecdd 100644 --- a/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h +++ b/dbms/src/Storages/MergeTree/MergedBlockOutputStream.h @@ -92,13 +92,13 @@ public: MergedBlockOutputStream( MergeTreeData & storage_, String part_path_, - const NamesAndTypes & columns_list_, + const NamesAndTypesList & columns_list_, CompressionSettings compression_settings); MergedBlockOutputStream( MergeTreeData & storage_, String part_path_, - const NamesAndTypes & columns_list_, + const NamesAndTypesList & columns_list_, CompressionSettings compression_settings, const MergeTreeData::DataPart::ColumnToSize & merged_column_to_size_, size_t aio_threshold_); @@ -117,7 +117,7 @@ public: void writeSuffixAndFinalizePart( MergeTreeData::MutableDataPartPtr & new_part, - const NamesAndTypes * total_columns_list = nullptr, + const NamesAndTypesList * total_columns_list = nullptr, MergeTreeData::DataPart::Checksums * additional_column_checksums = nullptr); /// How many rows are already written. @@ -132,7 +132,7 @@ private: void writeImpl(const Block & block, const IColumn::Permutation * permutation); private: - NamesAndTypes columns_list; + NamesAndTypesList columns_list; String part_path; size_t rows_count = 0; diff --git a/dbms/src/Storages/MergeTree/PKCondition.cpp b/dbms/src/Storages/MergeTree/PKCondition.cpp index 2d5853126af..212c26d3732 100644 --- a/dbms/src/Storages/MergeTree/PKCondition.cpp +++ b/dbms/src/Storages/MergeTree/PKCondition.cpp @@ -202,7 +202,7 @@ inline bool Range::less(const Field & lhs, const Field & rhs) { return applyVisi * For index to work when something like "WHERE Date = toDate(now())" is written. */ Block PKCondition::getBlockWithConstants( - const ASTPtr & query, const Context & context, const NamesAndTypes & all_columns) + const ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns) { Block result { @@ -221,7 +221,7 @@ Block PKCondition::getBlockWithConstants( PKCondition::PKCondition( const SelectQueryInfo & query_info, const Context & context, - const NamesAndTypes & all_columns, + const NamesAndTypesList & all_columns, const SortDescription & sort_descr_, const ExpressionActionsPtr & pk_expr_) : sort_descr(sort_descr_), pk_expr(pk_expr_), prepared_sets(query_info.sets) diff --git a/dbms/src/Storages/MergeTree/PKCondition.h b/dbms/src/Storages/MergeTree/PKCondition.h index f2bab0db03e..ab96a160162 100644 --- a/dbms/src/Storages/MergeTree/PKCondition.h +++ b/dbms/src/Storages/MergeTree/PKCondition.h @@ -205,7 +205,7 @@ public: PKCondition( const SelectQueryInfo & query_info, const Context & context, - const NamesAndTypes & all_columns, + const NamesAndTypesList & all_columns, const SortDescription & sort_descr, const ExpressionActionsPtr & pk_expr); @@ -276,7 +276,7 @@ public: }; static Block getBlockWithConstants( - const ASTPtr & query, const Context & context, const NamesAndTypes & all_columns); + const ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns); using AtomMap = std::unordered_map; static const AtomMap atom_map; diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp index 09a34d73c0c..f64826f6266 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.cpp @@ -241,7 +241,7 @@ void ReplicatedMergeTreePartCheckThread::checkPart(const String & part_name) zookeeper->get(storage.replica_path + "/parts/" + part_name + "/checksums")); zk_checksums.checkEqual(part->checksums, true); - auto zk_columns = NamesAndTypes::parse( + auto zk_columns = NamesAndTypesList::parse( zookeeper->get(storage.replica_path + "/parts/" + part_name + "/columns")); if (part->columns != zk_columns) throw Exception("Columns of local part " + part_name + " are different from ZooKeeper"); diff --git a/dbms/src/Storages/MergeTree/checkDataPart.cpp b/dbms/src/Storages/MergeTree/checkDataPart.cpp index b8719f0b32d..1c25112ca39 100644 --- a/dbms/src/Storages/MergeTree/checkDataPart.cpp +++ b/dbms/src/Storages/MergeTree/checkDataPart.cpp @@ -153,7 +153,7 @@ MergeTreeData::DataPart::Checksums checkDataPart( if (!path.empty() && path.back() != '/') path += "/"; - NamesAndTypes columns; + NamesAndTypesList columns; { ReadBufferFromFile buf(path + "columns.txt"); @@ -239,7 +239,7 @@ MergeTreeData::DataPart::Checksums checkDataPart( } /// Read all columns, calculate checksums and validate marks. - for (const NameAndType & name_type : columns) + for (const NameAndTypePair & name_type : columns) { LOG_DEBUG(log, "Checking column " + name_type.name + " in " + path); diff --git a/dbms/src/Storages/StorageBuffer.cpp b/dbms/src/Storages/StorageBuffer.cpp index 5b45eca2991..5bc114a50d0 100644 --- a/dbms/src/Storages/StorageBuffer.cpp +++ b/dbms/src/Storages/StorageBuffer.cpp @@ -43,9 +43,9 @@ namespace ErrorCodes } -StorageBuffer::StorageBuffer(const std::string & name_, const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, +StorageBuffer::StorageBuffer(const std::string & name_, const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, size_t num_shards_, const Thresholds & min_thresholds_, const Thresholds & max_thresholds_, diff --git a/dbms/src/Storages/StorageBuffer.h b/dbms/src/Storages/StorageBuffer.h index 46142e89039..161e5d7ed10 100644 --- a/dbms/src/Storages/StorageBuffer.h +++ b/dbms/src/Storages/StorageBuffer.h @@ -53,7 +53,7 @@ public: std::string getName() const override { return "Buffer"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -82,7 +82,7 @@ public: private: String name; - NamesAndTypes columns; + NamesAndTypesList columns; Context & context; @@ -125,9 +125,9 @@ protected: /** num_shards - the level of internal parallelism (the number of independent buffers) * The buffer is flushed if all minimum thresholds or at least one of the maximum thresholds are exceeded. */ - StorageBuffer(const std::string & name_, const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + StorageBuffer(const std::string & name_, const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, size_t num_shards_, const Thresholds & min_thresholds_, const Thresholds & max_thresholds_, diff --git a/dbms/src/Storages/StorageCatBoostPool.cpp b/dbms/src/Storages/StorageCatBoostPool.cpp index 2de2779478d..6f5bfd7924d 100644 --- a/dbms/src/Storages/StorageCatBoostPool.cpp +++ b/dbms/src/Storages/StorageCatBoostPool.cpp @@ -232,8 +232,8 @@ void StorageCatBoostPool::parseColumnDescription() void StorageCatBoostPool::createSampleBlockAndColumns() { columns.clear(); - NamesAndTypes cat_columns; - NamesAndTypes num_columns; + NamesAndTypesList cat_columns; + NamesAndTypesList num_columns; sample_block.clear(); for (auto & desc : columns_description) { diff --git a/dbms/src/Storages/StorageCatBoostPool.h b/dbms/src/Storages/StorageCatBoostPool.h index 9901c9c246a..35d20e0c9a9 100644 --- a/dbms/src/Storages/StorageCatBoostPool.h +++ b/dbms/src/Storages/StorageCatBoostPool.h @@ -17,7 +17,7 @@ public: std::string getTableName() const override { return table_name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read(const Names & column_names, const SelectQueryInfo & query_info, @@ -28,7 +28,7 @@ public: private: String table_name; - NamesAndTypes columns; + NamesAndTypesList columns; String column_description_file_name; String data_description_file_name; Block sample_block; diff --git a/dbms/src/Storages/StorageDictionary.cpp b/dbms/src/Storages/StorageDictionary.cpp index 5633598b967..ffabf37ec67 100644 --- a/dbms/src/Storages/StorageDictionary.cpp +++ b/dbms/src/Storages/StorageDictionary.cpp @@ -17,9 +17,9 @@ StoragePtr StorageDictionary::create( const String & table_name, Context & context, const ASTCreateQuery & query, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults) { const ASTFunction & engine = *query.storage->engine; @@ -40,9 +40,9 @@ StoragePtr StorageDictionary::create( StoragePtr StorageDictionary::create( const String & table_name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const DictionaryStructure & dictionary_structure, const String & dictionary_name) @@ -54,9 +54,9 @@ StoragePtr StorageDictionary::create( StorageDictionary::StorageDictionary( const String & table_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const DictionaryStructure & dictionary_structure_, const String & dictionary_name_) @@ -80,9 +80,9 @@ BlockInputStreams StorageDictionary::read( return BlockInputStreams{dictionary->getBlockInputStream(column_names, max_block_size)}; } -NamesAndTypes StorageDictionary::getNamesAndTypes(const DictionaryStructure & dictionary_structure) +NamesAndTypesList StorageDictionary::getNamesAndTypes(const DictionaryStructure & dictionary_structure) { - NamesAndTypes dictionary_names_and_types; + NamesAndTypesList dictionary_names_and_types; if (dictionary_structure.id) dictionary_names_and_types.emplace_back(dictionary_structure.id->name, std::make_shared()); @@ -103,7 +103,7 @@ NamesAndTypes StorageDictionary::getNamesAndTypes(const DictionaryStructure & di void StorageDictionary::checkNamesAndTypesCompatibleWithDictionary(const DictionaryStructure & dictionary_structure) const { auto dictionary_names_and_types = getNamesAndTypes(dictionary_structure); - std::set namesAndTypesSet(dictionary_names_and_types.begin(), dictionary_names_and_types.end()); + std::set namesAndTypesSet(dictionary_names_and_types.begin(), dictionary_names_and_types.end()); for (auto & column : columns) { diff --git a/dbms/src/Storages/StorageDictionary.h b/dbms/src/Storages/StorageDictionary.h index 052e4a1d74e..d777e55516d 100644 --- a/dbms/src/Storages/StorageDictionary.h +++ b/dbms/src/Storages/StorageDictionary.h @@ -23,22 +23,22 @@ public: static StoragePtr create(const String & table_name_, Context & context_, const ASTCreateQuery & query, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); static StoragePtr create(const String & table_name, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, const DictionaryStructure & dictionary_structure, const String & dictionary_name); std::string getName() const override { return "Dictionary"; } std::string getTableName() const override { return table_name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read(const Names & column_names, const SelectQueryInfo & query_info, const Context & context, @@ -47,13 +47,13 @@ public: unsigned threads = 1) override; void drop() override {} - static NamesAndTypes getNamesAndTypes(const DictionaryStructure & dictionary_structure); + static NamesAndTypesList getNamesAndTypes(const DictionaryStructure & dictionary_structure); private: using Ptr = MultiVersion::Version; String table_name; - NamesAndTypes columns; + NamesAndTypesList columns; String dictionary_name; Poco::Logger * logger; @@ -79,9 +79,9 @@ private: protected: StorageDictionary(const String & table_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const DictionaryStructure & dictionary_structure_, const String & dictionary_name_); diff --git a/dbms/src/Storages/StorageDistributed.cpp b/dbms/src/Storages/StorageDistributed.cpp index 22662b9e3f0..fd8b36ce978 100644 --- a/dbms/src/Storages/StorageDistributed.cpp +++ b/dbms/src/Storages/StorageDistributed.cpp @@ -127,7 +127,7 @@ StorageDistributed::~StorageDistributed() = default; StorageDistributed::StorageDistributed( const std::string & name_, - const NamesAndTypes & columns_, + const NamesAndTypesList & columns_, const String & remote_database_, const String & remote_table_, const String & cluster_name_, @@ -146,9 +146,9 @@ StorageDistributed::StorageDistributed( StorageDistributed::StorageDistributed( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & remote_database_, const String & remote_table_, @@ -169,7 +169,7 @@ StorageDistributed::StorageDistributed( StoragePtr StorageDistributed::createWithOwnCluster( const std::string & name_, - const NamesAndTypes & columns_, + const NamesAndTypesList & columns_, const String & remote_database_, const String & remote_table_, ClusterPtr & owned_cluster_, @@ -303,7 +303,7 @@ BlockInputStreams StorageDistributed::describe(const Context & context, const Se } -NameAndType StorageDistributed::getColumn(const String & column_name) const +NameAndTypePair StorageDistributed::getColumn(const String & column_name) const { if (const auto & type = VirtualColumnFactory::tryGetType(column_name)) return { column_name, type }; diff --git a/dbms/src/Storages/StorageDistributed.h b/dbms/src/Storages/StorageDistributed.h index 3664eac9854..b97c99aba8f 100644 --- a/dbms/src/Storages/StorageDistributed.h +++ b/dbms/src/Storages/StorageDistributed.h @@ -35,7 +35,7 @@ public: static StoragePtr createWithOwnCluster( const std::string & name_, /// The name of the table. - const NamesAndTypes & columns_, /// List of columns. + const NamesAndTypesList & columns_, /// List of columns. const String & remote_database_, /// database on remote servers. const String & remote_table_, /// The name of the table on the remote servers. ClusterPtr & owned_cluster_, @@ -47,8 +47,8 @@ public: bool supportsFinal() const override { return true; } bool supportsPrewhere() const override { return true; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } - NameAndType getColumn(const String & column_name) const override; + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } + NameAndTypePair getColumn(const String & column_name) const override; bool hasColumn(const String & column_name) const override; bool isRemote() const override { return true; } @@ -94,7 +94,7 @@ public: String name; - NamesAndTypes columns; + NamesAndTypesList columns; String remote_database; String remote_table; @@ -130,7 +130,7 @@ public: protected: StorageDistributed( const std::string & name_, - const NamesAndTypes & columns_, + const NamesAndTypesList & columns_, const String & remote_database_, const String & remote_table_, const String & cluster_name_, @@ -140,9 +140,9 @@ protected: StorageDistributed( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & remote_database_, const String & remote_table_, diff --git a/dbms/src/Storages/StorageFactory.cpp b/dbms/src/Storages/StorageFactory.cpp index a05d3f23a67..1dc4f67278b 100644 --- a/dbms/src/Storages/StorageFactory.cpp +++ b/dbms/src/Storages/StorageFactory.cpp @@ -239,7 +239,7 @@ static void setGraphitePatternsFromConfig(const Context & context, /// Some types are only for intermediate values of expressions and cannot be used in tables. -static void checkAllTypesAreAllowedInTable(const NamesAndTypes & names_and_types) +static void checkAllTypesAreAllowedInTable(const NamesAndTypesList & names_and_types) { for (const auto & elem : names_and_types) if (elem.type->cannotBeStoredInTables()) @@ -365,9 +365,9 @@ StoragePtr StorageFactory::get( const String & database_name, Context & local_context, Context & context, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, bool attach, bool has_force_restore_data_flag) const diff --git a/dbms/src/Storages/StorageFactory.h b/dbms/src/Storages/StorageFactory.h index fbbb2330cf0..2360bf4f12e 100644 --- a/dbms/src/Storages/StorageFactory.h +++ b/dbms/src/Storages/StorageFactory.h @@ -24,9 +24,9 @@ public: const String & database_name, Context & local_context, Context & context, - const NamesAndTypes & columns, - const NamesAndTypes & materialized_columns, - const NamesAndTypes & alias_columns, + const NamesAndTypesList & columns, + const NamesAndTypesList & materialized_columns, + const NamesAndTypesList & alias_columns, const ColumnDefaults & column_defaults, bool attach, bool has_force_restore_data_flag) const; diff --git a/dbms/src/Storages/StorageFile.cpp b/dbms/src/Storages/StorageFile.cpp index f95b7be5ffa..413d591d7e8 100644 --- a/dbms/src/Storages/StorageFile.cpp +++ b/dbms/src/Storages/StorageFile.cpp @@ -42,9 +42,9 @@ StorageFile::StorageFile( const std::string & db_dir_path, const std::string & table_name_, const std::string & format_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_) : IStorage(materialized_columns_, alias_columns_, column_defaults_), diff --git a/dbms/src/Storages/StorageFile.h b/dbms/src/Storages/StorageFile.h index 37292275782..58bb8bc1e9d 100644 --- a/dbms/src/Storages/StorageFile.h +++ b/dbms/src/Storages/StorageFile.h @@ -31,7 +31,7 @@ public: return table_name; } - const NamesAndTypes & getColumnsListImpl() const override + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } @@ -67,9 +67,9 @@ protected: const std::string & db_dir_path, const std::string & table_name_, const std::string & format_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_); @@ -77,7 +77,7 @@ private: std::string table_name; std::string format_name; - NamesAndTypes columns; + NamesAndTypesList columns; Context & context_global; std::string path; diff --git a/dbms/src/Storages/StorageJoin.cpp b/dbms/src/Storages/StorageJoin.cpp index 060da7765bb..0296bfe148c 100644 --- a/dbms/src/Storages/StorageJoin.cpp +++ b/dbms/src/Storages/StorageJoin.cpp @@ -18,15 +18,15 @@ StorageJoin::StorageJoin( const String & name_, const Names & key_names_, ASTTableJoin::Kind kind_, ASTTableJoin::Strictness strictness_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : StorageSetOrJoinBase{path_, name_, columns_, materialized_columns_, alias_columns_, column_defaults_}, key_names(key_names_), kind(kind_), strictness(strictness_) { /// Check that key exists in table definition. - const auto check_key_exists = [] (const NamesAndTypes & columns, const String & key) + const auto check_key_exists = [] (const NamesAndTypesList & columns, const String & key) { for (const auto & column : columns) if (column.name == key) diff --git a/dbms/src/Storages/StorageJoin.h b/dbms/src/Storages/StorageJoin.h index f12f990be38..135236beddb 100644 --- a/dbms/src/Storages/StorageJoin.h +++ b/dbms/src/Storages/StorageJoin.h @@ -47,9 +47,9 @@ protected: const String & name_, const Names & key_names_, ASTTableJoin::Kind kind_, ASTTableJoin::Strictness strictness_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); }; diff --git a/dbms/src/Storages/StorageKafka.cpp b/dbms/src/Storages/StorageKafka.cpp index fa8810b4094..7017a93f85b 100644 --- a/dbms/src/Storages/StorageKafka.cpp +++ b/dbms/src/Storages/StorageKafka.cpp @@ -217,9 +217,9 @@ StorageKafka::StorageKafka( const std::string & table_name_, const std::string & database_name_, Context & context_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & brokers_, const String & group_, const Names & topics_, const String & format_name_, const String & schema_name_, size_t num_consumers_) diff --git a/dbms/src/Storages/StorageKafka.h b/dbms/src/Storages/StorageKafka.h index dd519494786..a41fee8f747 100644 --- a/dbms/src/Storages/StorageKafka.h +++ b/dbms/src/Storages/StorageKafka.h @@ -32,7 +32,7 @@ public: std::string getTableName() const override { return table_name; } std::string getDatabaseName() const { return database_name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } void startup() override; void shutdown() override; @@ -73,7 +73,7 @@ private: String table_name; String database_name; Context & context; - NamesAndTypes columns; + NamesAndTypesList columns; Names topics; const String brokers; const String group; @@ -105,9 +105,9 @@ protected: const std::string & table_name_, const std::string & database_name_, Context & context_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & brokers_, const String & group_, const Names & topics_, const String & format_name_, const String & schema_name_, size_t num_consumers_); diff --git a/dbms/src/Storages/StorageLog.cpp b/dbms/src/Storages/StorageLog.cpp index 35c51f66061..ef6bd792f7b 100644 --- a/dbms/src/Storages/StorageLog.cpp +++ b/dbms/src/Storages/StorageLog.cpp @@ -392,9 +392,9 @@ void LogBlockOutputStream::writeMarks(MarksForColumns && marks) StorageLog::StorageLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, size_t max_compress_block_size_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, diff --git a/dbms/src/Storages/StorageLog.h b/dbms/src/Storages/StorageLog.h index b0173698c91..740454f6fce 100644 --- a/dbms/src/Storages/StorageLog.h +++ b/dbms/src/Storages/StorageLog.h @@ -26,7 +26,7 @@ public: std::string getName() const override { return "Log"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -50,16 +50,16 @@ protected: StorageLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, size_t max_compress_block_size_); private: String path; String name; - NamesAndTypes columns; + NamesAndTypesList columns; mutable std::shared_mutex rwlock; diff --git a/dbms/src/Storages/StorageMaterializedView.cpp b/dbms/src/Storages/StorageMaterializedView.cpp index 82d5f044ef3..ada6a9e3054 100644 --- a/dbms/src/Storages/StorageMaterializedView.cpp +++ b/dbms/src/Storages/StorageMaterializedView.cpp @@ -59,9 +59,9 @@ StorageMaterializedView::StorageMaterializedView( const String & database_name_, Context & local_context, const ASTCreateQuery & query, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, table_name(table_name_), @@ -126,7 +126,7 @@ StorageMaterializedView::StorageMaterializedView( } } -NameAndType StorageMaterializedView::getColumn(const String & column_name) const +NameAndTypePair StorageMaterializedView::getColumn(const String & column_name) const { return getTargetTable()->getColumn(column_name); } diff --git a/dbms/src/Storages/StorageMaterializedView.h b/dbms/src/Storages/StorageMaterializedView.h index 260e231f9a0..b153a4e864b 100644 --- a/dbms/src/Storages/StorageMaterializedView.h +++ b/dbms/src/Storages/StorageMaterializedView.h @@ -17,11 +17,11 @@ class StorageMaterializedView : public ext::shared_ptr_helperclone(); }; StoragePtr getTargetTable() const; - NameAndType getColumn(const String & column_name) const override; + NameAndTypePair getColumn(const String & column_name) const override; bool hasColumn(const String & column_name) const override; bool supportsSampling() const override { return getTargetTable()->supportsSampling(); } @@ -51,7 +51,7 @@ private: String database_name; ASTPtr inner_query; Context & global_context; - NamesAndTypes columns; + NamesAndTypesList columns; bool has_inner_table = false; protected: @@ -60,9 +60,9 @@ protected: const String & database_name_, Context & local_context, const ASTCreateQuery & query, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach_); }; diff --git a/dbms/src/Storages/StorageMemory.cpp b/dbms/src/Storages/StorageMemory.cpp index 7a4d15dcf7c..b4f0b389f5b 100644 --- a/dbms/src/Storages/StorageMemory.cpp +++ b/dbms/src/Storages/StorageMemory.cpp @@ -76,9 +76,9 @@ private: StorageMemory::StorageMemory( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, name(name_), columns(columns_) diff --git a/dbms/src/Storages/StorageMemory.h b/dbms/src/Storages/StorageMemory.h index b1a7369eb33..255434e9e34 100644 --- a/dbms/src/Storages/StorageMemory.h +++ b/dbms/src/Storages/StorageMemory.h @@ -26,7 +26,7 @@ public: std::string getName() const override { return "Memory"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } size_t getSize() const { return data.size(); } @@ -45,7 +45,7 @@ public: private: String name; - NamesAndTypes columns; + NamesAndTypesList columns; /// The data itself. `list` - so that when inserted to the end, the existing iterators are not invalidated. BlocksList data; @@ -55,9 +55,9 @@ private: protected: StorageMemory( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); }; diff --git a/dbms/src/Storages/StorageMerge.cpp b/dbms/src/Storages/StorageMerge.cpp index c06b317b886..f57eeb4c8fb 100644 --- a/dbms/src/Storages/StorageMerge.cpp +++ b/dbms/src/Storages/StorageMerge.cpp @@ -31,9 +31,9 @@ namespace ErrorCodes StorageMerge::StorageMerge( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & source_database_, const String & table_name_regexp_, @@ -64,11 +64,11 @@ bool StorageMerge::isRemote() const return false; } -NameAndType StorageMerge::getColumn(const String & column_name) const +NameAndTypePair StorageMerge::getColumn(const String & column_name) const { auto type = VirtualColumnFactory::tryGetType(column_name); if (type) - return NameAndType(column_name, type); + return NameAndTypePair(column_name, type); return IStorage::getColumn(column_name); } diff --git a/dbms/src/Storages/StorageMerge.h b/dbms/src/Storages/StorageMerge.h index 3c6a5923524..9ceae8f92ea 100644 --- a/dbms/src/Storages/StorageMerge.h +++ b/dbms/src/Storages/StorageMerge.h @@ -26,8 +26,8 @@ public: bool supportsFinal() const override { return true; } bool supportsIndexForIn() const override { return true; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } - NameAndType getColumn(const String & column_name) const override; + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } + NameAndTypePair getColumn(const String & column_name) const override; bool hasColumn(const String & column_name) const override; BlockInputStreams read( @@ -47,7 +47,7 @@ public: private: String name; - NamesAndTypes columns; + NamesAndTypesList columns; String source_database; OptimizedRegularExpression table_name_regexp; const Context & context; @@ -61,9 +61,9 @@ private: protected: StorageMerge( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, const String & source_database_, const String & table_name_regexp_, diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index a7de649556d..18a3faa7b60 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -34,9 +34,9 @@ StorageMergeTree::StorageMergeTree( const String & path_, const String & database_name_, const String & table_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, Context & context_, diff --git a/dbms/src/Storages/StorageMergeTree.h b/dbms/src/Storages/StorageMergeTree.h index c819087800b..ed8172781a8 100644 --- a/dbms/src/Storages/StorageMergeTree.h +++ b/dbms/src/Storages/StorageMergeTree.h @@ -35,9 +35,9 @@ public: bool supportsFinal() const override { return data.supportsFinal(); } bool supportsPrewhere() const override { return data.supportsPrewhere(); } - const NamesAndTypes & getColumnsListImpl() const override { return data.getColumnsListNonMaterialized(); } + const NamesAndTypesList & getColumnsListImpl() const override { return data.getColumnsListNonMaterialized(); } - NameAndType getColumn(const String & column_name) const override + NameAndTypePair getColumn(const String & column_name) const override { return data.getColumn(column_name); } @@ -131,9 +131,9 @@ protected: const String & path_, const String & database_name_, const String & table_name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, Context & context_, diff --git a/dbms/src/Storages/StorageNull.h b/dbms/src/Storages/StorageNull.h index d169574dea7..105b53b44de 100644 --- a/dbms/src/Storages/StorageNull.h +++ b/dbms/src/Storages/StorageNull.h @@ -20,7 +20,7 @@ public: std::string getName() const override { return "Null"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names &, @@ -45,14 +45,14 @@ public: private: String name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageNull( const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, name(name_), columns(columns_) {} }; diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.cpp b/dbms/src/Storages/StorageReplicatedMergeTree.cpp index 33991b7f1b8..b9a73cc6745 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.cpp +++ b/dbms/src/Storages/StorageReplicatedMergeTree.cpp @@ -165,9 +165,9 @@ StorageReplicatedMergeTree::StorageReplicatedMergeTree( const String & replica_name_, bool attach, const String & path_, const String & database_name_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, const ASTPtr & primary_expr_ast_, @@ -2411,9 +2411,9 @@ void StorageReplicatedMergeTree::alter(const AlterCommands & params, if (param.type == AlterCommand::MODIFY_PRIMARY_KEY) throw Exception("Modification of primary key is not supported for replicated tables", ErrorCodes::NOT_IMPLEMENTED); - NamesAndTypes new_columns = data.getColumnsListNonMaterialized(); - NamesAndTypes new_materialized_columns = data.materialized_columns; - NamesAndTypes new_alias_columns = data.alias_columns; + NamesAndTypesList new_columns = data.getColumnsListNonMaterialized(); + NamesAndTypesList new_materialized_columns = data.materialized_columns; + NamesAndTypesList new_alias_columns = data.alias_columns; ColumnDefaults new_column_defaults = data.column_defaults; params.apply(new_columns, new_materialized_columns, new_alias_columns, new_column_defaults); diff --git a/dbms/src/Storages/StorageReplicatedMergeTree.h b/dbms/src/Storages/StorageReplicatedMergeTree.h index fc1e9444ab0..043497d0a59 100644 --- a/dbms/src/Storages/StorageReplicatedMergeTree.h +++ b/dbms/src/Storages/StorageReplicatedMergeTree.h @@ -84,9 +84,9 @@ public: bool supportsPrewhere() const override { return data.supportsPrewhere(); } bool supportsReplication() const override { return true; } - const NamesAndTypes & getColumnsListImpl() const override { return data.getColumnsListNonMaterialized(); } + const NamesAndTypesList & getColumnsListImpl() const override { return data.getColumnsListNonMaterialized(); } - NameAndType getColumn(const String & column_name) const override + NameAndTypePair getColumn(const String & column_name) const override { return data.getColumn(column_name); } @@ -431,9 +431,9 @@ protected: const String & replica_name_, bool attach, const String & path_, const String & database_name_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, Context & context_, const ASTPtr & primary_expr_ast_, diff --git a/dbms/src/Storages/StorageSet.cpp b/dbms/src/Storages/StorageSet.cpp index 5037d225de6..11604b9d365 100644 --- a/dbms/src/Storages/StorageSet.cpp +++ b/dbms/src/Storages/StorageSet.cpp @@ -76,9 +76,9 @@ BlockOutputStreamPtr StorageSetOrJoinBase::write(const ASTPtr & /*query*/, const StorageSetOrJoinBase::StorageSetOrJoinBase( const String & path_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, path(path_ + escapeForFileName(name_) + '/'), name(name_), columns(columns_) @@ -90,9 +90,9 @@ StorageSetOrJoinBase::StorageSetOrJoinBase( StorageSet::StorageSet( const String & path_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : StorageSetOrJoinBase{path_, name_, columns_, materialized_columns_, alias_columns_, column_defaults_}, set(std::make_shared(Limits{})) diff --git a/dbms/src/Storages/StorageSet.h b/dbms/src/Storages/StorageSet.h index a3b6cb6a777..bd5045208de 100644 --- a/dbms/src/Storages/StorageSet.h +++ b/dbms/src/Storages/StorageSet.h @@ -20,7 +20,7 @@ class StorageSetOrJoinBase : public IStorage public: String getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } void rename(const String & new_path_to_db, const String & new_database_name, const String & new_table_name) override; @@ -30,14 +30,14 @@ protected: StorageSetOrJoinBase( const String & path_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); String path; String name; - NamesAndTypes columns; + NamesAndTypesList columns; UInt64 increment = 0; /// For the backup file names. @@ -78,9 +78,9 @@ protected: StorageSet( const String & path_, const String & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); }; diff --git a/dbms/src/Storages/StorageStripeLog.cpp b/dbms/src/Storages/StorageStripeLog.cpp index 2c419d53276..9596f92da47 100644 --- a/dbms/src/Storages/StorageStripeLog.cpp +++ b/dbms/src/Storages/StorageStripeLog.cpp @@ -175,9 +175,9 @@ private: StorageStripeLog::StorageStripeLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, size_t max_compress_block_size_) diff --git a/dbms/src/Storages/StorageStripeLog.h b/dbms/src/Storages/StorageStripeLog.h index cfe8888ce60..4d7e615c5b1 100644 --- a/dbms/src/Storages/StorageStripeLog.h +++ b/dbms/src/Storages/StorageStripeLog.h @@ -28,7 +28,7 @@ public: std::string getName() const override { return "StripeLog"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -56,7 +56,7 @@ public: private: String path; String name; - NamesAndTypes columns; + NamesAndTypesList columns; size_t max_compress_block_size; @@ -69,9 +69,9 @@ protected: StorageStripeLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, size_t max_compress_block_size_ = DEFAULT_MAX_COMPRESS_BLOCK_SIZE); diff --git a/dbms/src/Storages/StorageTinyLog.cpp b/dbms/src/Storages/StorageTinyLog.cpp index 4d12e21f821..022cc0151c9 100644 --- a/dbms/src/Storages/StorageTinyLog.cpp +++ b/dbms/src/Storages/StorageTinyLog.cpp @@ -308,9 +308,9 @@ void TinyLogBlockOutputStream::write(const Block & block) StorageTinyLog::StorageTinyLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, size_t max_compress_block_size_) diff --git a/dbms/src/Storages/StorageTinyLog.h b/dbms/src/Storages/StorageTinyLog.h index 00dfbe49b1f..e26c9ad6395 100644 --- a/dbms/src/Storages/StorageTinyLog.h +++ b/dbms/src/Storages/StorageTinyLog.h @@ -27,7 +27,7 @@ public: std::string getName() const override { return "TinyLog"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -55,7 +55,7 @@ public: private: String path; String name; - NamesAndTypes columns; + NamesAndTypesList columns; size_t max_compress_block_size; @@ -72,9 +72,9 @@ protected: StorageTinyLog( const std::string & path_, const std::string & name_, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_, bool attach, size_t max_compress_block_size_ = DEFAULT_MAX_COMPRESS_BLOCK_SIZE); diff --git a/dbms/src/Storages/StorageView.cpp b/dbms/src/Storages/StorageView.cpp index 8f0ffaaf4e2..b3c13564f45 100644 --- a/dbms/src/Storages/StorageView.cpp +++ b/dbms/src/Storages/StorageView.cpp @@ -20,9 +20,9 @@ StorageView::StorageView( const String & table_name_, const String & database_name_, const ASTCreateQuery & query, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_) : IStorage{materialized_columns_, alias_columns_, column_defaults_}, table_name(table_name_), database_name(database_name_), columns(columns_) diff --git a/dbms/src/Storages/StorageView.h b/dbms/src/Storages/StorageView.h index c235c5e11f6..675f92f3cad 100644 --- a/dbms/src/Storages/StorageView.h +++ b/dbms/src/Storages/StorageView.h @@ -16,7 +16,7 @@ class StorageView : public ext::shared_ptr_helper, public IStorage public: std::string getName() const override { return "View"; } std::string getTableName() const override { return table_name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } /// It is passed inside the query and solved at its level. bool supportsSampling() const override { return true; } @@ -36,16 +36,16 @@ private: String table_name; String database_name; ASTPtr inner_query; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageView( const String & table_name_, const String & database_name_, const ASTCreateQuery & query, - const NamesAndTypes & columns_, - const NamesAndTypes & materialized_columns_, - const NamesAndTypes & alias_columns_, + const NamesAndTypesList & columns_, + const NamesAndTypesList & materialized_columns_, + const NamesAndTypesList & alias_columns_, const ColumnDefaults & column_defaults_); }; diff --git a/dbms/src/Storages/System/StorageSystemAsynchronousMetrics.h b/dbms/src/Storages/System/StorageSystemAsynchronousMetrics.h index cb9326b6f45..560265e1dab 100644 --- a/dbms/src/Storages/System/StorageSystemAsynchronousMetrics.h +++ b/dbms/src/Storages/System/StorageSystemAsynchronousMetrics.h @@ -19,7 +19,7 @@ public: std::string getName() const override { return "SystemAsynchronousMetrics"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -31,7 +31,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; const AsynchronousMetrics & async_metrics; protected: diff --git a/dbms/src/Storages/System/StorageSystemBuildOptions.h b/dbms/src/Storages/System/StorageSystemBuildOptions.h index 718ee8bd1c3..a1ecae77b3a 100644 --- a/dbms/src/Storages/System/StorageSystemBuildOptions.h +++ b/dbms/src/Storages/System/StorageSystemBuildOptions.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemBuildOptions"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemBuildOptions(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemClusters.h b/dbms/src/Storages/System/StorageSystemClusters.h index 025631d55e2..c8113d4d095 100644 --- a/dbms/src/Storages/System/StorageSystemClusters.h +++ b/dbms/src/Storages/System/StorageSystemClusters.h @@ -18,7 +18,7 @@ class StorageSystemClusters : public ext::shared_ptr_helper(); const std::string table_name = (*filtered_table_column)[i].get(); - NamesAndTypes columns; + NamesAndTypesList columns; ColumnDefaults column_defaults; MergeTreeData::ColumnSizes column_sizes; diff --git a/dbms/src/Storages/System/StorageSystemColumns.h b/dbms/src/Storages/System/StorageSystemColumns.h index 210e05e08f0..bd7dfbf21ce 100644 --- a/dbms/src/Storages/System/StorageSystemColumns.h +++ b/dbms/src/Storages/System/StorageSystemColumns.h @@ -16,7 +16,7 @@ class StorageSystemColumns : public ext::shared_ptr_helper public: std::string getName() const override { return "SystemColumns"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -31,7 +31,7 @@ protected: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; }; } diff --git a/dbms/src/Storages/System/StorageSystemDatabases.h b/dbms/src/Storages/System/StorageSystemDatabases.h index 2036378522d..c574861a94d 100644 --- a/dbms/src/Storages/System/StorageSystemDatabases.h +++ b/dbms/src/Storages/System/StorageSystemDatabases.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemDatabases"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemDatabases(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemDictionaries.h b/dbms/src/Storages/System/StorageSystemDictionaries.h index ffc7736b07f..a27bfbd21a4 100644 --- a/dbms/src/Storages/System/StorageSystemDictionaries.h +++ b/dbms/src/Storages/System/StorageSystemDictionaries.h @@ -26,9 +26,9 @@ public: private: const std::string name; - const NamesAndTypes columns; + const NamesAndTypesList columns; - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } protected: StorageSystemDictionaries(const std::string & name); diff --git a/dbms/src/Storages/System/StorageSystemEvents.h b/dbms/src/Storages/System/StorageSystemEvents.h index 1c5a25ae713..4a0f2672cc1 100644 --- a/dbms/src/Storages/System/StorageSystemEvents.h +++ b/dbms/src/Storages/System/StorageSystemEvents.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemEvents"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemEvents(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemFunctions.h b/dbms/src/Storages/System/StorageSystemFunctions.h index 0c3b0142c85..c60515b92f3 100644 --- a/dbms/src/Storages/System/StorageSystemFunctions.h +++ b/dbms/src/Storages/System/StorageSystemFunctions.h @@ -18,7 +18,7 @@ class StorageSystemFunctions : public ext::shared_ptr_helperinsert(static_cast(part->marks_count)); size_t marks_size = 0; - for (const NameAndType & it : part->columns) + for (const NameAndTypePair & it : part->columns) { String name = escapeForFileName(it.name); auto checksum = part->checksums.files.find(name + ".mrk"); @@ -285,10 +285,10 @@ BlockInputStreams StorageSystemParts::read( return BlockInputStreams(1, std::make_shared(block.cloneWithColumns(std::move(res_columns)))); } -NameAndType StorageSystemParts::getColumn(const String & column_name) const +NameAndTypePair StorageSystemParts::getColumn(const String & column_name) const { if (column_name == "_state") - return NameAndType("_state", std::make_shared()); + return NameAndTypePair("_state", std::make_shared()); return ITableDeclaration::getColumn(column_name); } diff --git a/dbms/src/Storages/System/StorageSystemParts.h b/dbms/src/Storages/System/StorageSystemParts.h index 500e2c09ea6..bfbf77cfffb 100644 --- a/dbms/src/Storages/System/StorageSystemParts.h +++ b/dbms/src/Storages/System/StorageSystemParts.h @@ -18,9 +18,9 @@ public: std::string getName() const override { return "SystemParts"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } - NameAndType getColumn(const String & column_name) const override; + NameAndTypePair getColumn(const String & column_name) const override; bool hasColumn(const String & column_name) const override; @@ -34,7 +34,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemParts(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemProcesses.h b/dbms/src/Storages/System/StorageSystemProcesses.h index 830f1fa7b26..73da8cfc170 100644 --- a/dbms/src/Storages/System/StorageSystemProcesses.h +++ b/dbms/src/Storages/System/StorageSystemProcesses.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemProcesses"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemProcesses(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemReplicas.h b/dbms/src/Storages/System/StorageSystemReplicas.h index 5b20efb47e2..0140e94f9df 100644 --- a/dbms/src/Storages/System/StorageSystemReplicas.h +++ b/dbms/src/Storages/System/StorageSystemReplicas.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemReplicas"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemReplicas(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemReplicationQueue.h b/dbms/src/Storages/System/StorageSystemReplicationQueue.h index e8b8689b08b..369ace0ec36 100644 --- a/dbms/src/Storages/System/StorageSystemReplicationQueue.h +++ b/dbms/src/Storages/System/StorageSystemReplicationQueue.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemReplicationQueue"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemReplicationQueue(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemSettings.h b/dbms/src/Storages/System/StorageSystemSettings.h index 05eff1a0a0b..f48611c2519 100644 --- a/dbms/src/Storages/System/StorageSystemSettings.h +++ b/dbms/src/Storages/System/StorageSystemSettings.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemSettings"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemSettings(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemTables.h b/dbms/src/Storages/System/StorageSystemTables.h index 49270a3fe86..3dd66e0f409 100644 --- a/dbms/src/Storages/System/StorageSystemTables.h +++ b/dbms/src/Storages/System/StorageSystemTables.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemTables"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemTables(const std::string & name_); diff --git a/dbms/src/Storages/System/StorageSystemZooKeeper.h b/dbms/src/Storages/System/StorageSystemZooKeeper.h index 698785277d6..72913ab8beb 100644 --- a/dbms/src/Storages/System/StorageSystemZooKeeper.h +++ b/dbms/src/Storages/System/StorageSystemZooKeeper.h @@ -18,7 +18,7 @@ public: std::string getName() const override { return "SystemZooKeeper"; } std::string getTableName() const override { return name; } - const NamesAndTypes & getColumnsListImpl() const override { return columns; } + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } BlockInputStreams read( const Names & column_names, @@ -30,7 +30,7 @@ public: private: const std::string name; - NamesAndTypes columns; + NamesAndTypesList columns; protected: StorageSystemZooKeeper(const std::string & name_); diff --git a/dbms/src/Storages/VirtualColumnUtils.cpp b/dbms/src/Storages/VirtualColumnUtils.cpp index 6643496f9b0..5864d35da48 100644 --- a/dbms/src/Storages/VirtualColumnUtils.cpp +++ b/dbms/src/Storages/VirtualColumnUtils.cpp @@ -23,7 +23,7 @@ namespace DB namespace VirtualColumnUtils { -String chooseSuffix(const NamesAndTypes & columns, const String & name) +String chooseSuffix(const NamesAndTypesList & columns, const String & name) { int id = 0; String current_suffix; @@ -43,7 +43,7 @@ String chooseSuffix(const NamesAndTypes & columns, const String & name) return current_suffix; } -String chooseSuffixForSet(const NamesAndTypes & columns, const std::vector & names) +String chooseSuffixForSet(const NamesAndTypesList & columns, const std::vector & names) { int id = 0; String current_suffix; @@ -140,7 +140,7 @@ bool filterBlockWithQuery(const ASTPtr & query, Block & block, const Context & c return false; NameSet columns; - for (const auto & it : block.getNamesAndTypes()) + for (const auto & it : block.getNamesAndTypesList()) columns.insert(it.name); /// We will create an expression that evaluates the expressions in WHERE and PREWHERE, depending only on the existing columns. @@ -154,7 +154,7 @@ bool filterBlockWithQuery(const ASTPtr & query, Block & block, const Context & c return false; /// Let's analyze and calculate the expression. - ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getNamesAndTypes()); + ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getNamesAndTypesList()); ExpressionActionsPtr actions = analyzer.getActions(false); actions->execute(block); diff --git a/dbms/src/Storages/VirtualColumnUtils.h b/dbms/src/Storages/VirtualColumnUtils.h index 7455cb6d4b4..bfbd44cf2c8 100644 --- a/dbms/src/Storages/VirtualColumnUtils.h +++ b/dbms/src/Storages/VirtualColumnUtils.h @@ -10,18 +10,18 @@ namespace DB { class Context; -class NamesAndTypes; +class NamesAndTypesList; namespace VirtualColumnUtils { /// Calculate the minimum numeric suffix to add to the string so that it is not present in the set -String chooseSuffix(const NamesAndTypes & columns, const String & name); +String chooseSuffix(const NamesAndTypesList & columns, const String & name); /// Calculate the minimum total numeric suffix to add to each string, /// so that none is present in the set. -String chooseSuffixForSet(const NamesAndTypes & columns, const std::vector & names); +String chooseSuffixForSet(const NamesAndTypesList & columns, const std::vector & names); /// Adds to the select query section `select column_name as value` /// For example select _port as 9000. diff --git a/dbms/src/Storages/tests/hit_log.cpp b/dbms/src/Storages/tests/hit_log.cpp index 979799d5d56..bd1777db18f 100644 --- a/dbms/src/Storages/tests/hit_log.cpp +++ b/dbms/src/Storages/tests/hit_log.cpp @@ -27,7 +27,7 @@ using namespace DB; int main(int argc, char ** argv) try { - NamesAndTypes names_and_types_list + NamesAndTypesList names_and_types_list { {"WatchID", std::make_shared()}, {"JavaEnable", std::make_shared()}, @@ -99,7 +99,7 @@ try /// create a hit log table StoragePtr table = StorageLog::create("./", "HitLog", names_and_types_list, - NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); + NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); table->startup(); /// create a description of how to read data from the tab separated dump diff --git a/dbms/src/Storages/tests/storage_log.cpp b/dbms/src/Storages/tests/storage_log.cpp index 69be222d219..70c73d8c0b5 100644 --- a/dbms/src/Storages/tests/storage_log.cpp +++ b/dbms/src/Storages/tests/storage_log.cpp @@ -21,12 +21,12 @@ try /// create table with a pair of columns - NamesAndTypes names_and_types; + NamesAndTypesList names_and_types; names_and_types.emplace_back("a", std::make_shared()); names_and_types.emplace_back("b", std::make_shared()); StoragePtr table = StorageLog::create("./", "test", names_and_types, - NamesAndTypes{}, NamesAndTypes{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); + NamesAndTypesList{}, NamesAndTypesList{}, ColumnDefaults{}, DEFAULT_MAX_COMPRESS_BLOCK_SIZE); table->startup(); /// write into it diff --git a/dbms/src/TableFunctions/TableFunctionMerge.cpp b/dbms/src/TableFunctions/TableFunctionMerge.cpp index 8623e8bb25d..9c12cf32ae3 100644 --- a/dbms/src/TableFunctions/TableFunctionMerge.cpp +++ b/dbms/src/TableFunctions/TableFunctionMerge.cpp @@ -25,7 +25,7 @@ namespace ErrorCodes } -static NamesAndTypes chooseColumns(const String & source_database, const String & table_name_regexp_, const Context & context) +static NamesAndTypesList chooseColumns(const String & source_database, const String & table_name_regexp_, const Context & context) { OptimizedRegularExpression table_name_regexp(table_name_regexp_); @@ -80,8 +80,8 @@ StoragePtr TableFunctionMerge::execute(const ASTPtr & ast_function, const Contex auto res = StorageMerge::create( getName(), chooseColumns(source_database, table_name_regexp, context), - NamesAndTypes{}, - NamesAndTypes{}, + NamesAndTypesList{}, + NamesAndTypesList{}, ColumnDefaults{}, source_database, table_name_regexp, diff --git a/dbms/src/TableFunctions/getStructureOfRemoteTable.cpp b/dbms/src/TableFunctions/getStructureOfRemoteTable.cpp index 0044538aa3d..81f1cce93cf 100644 --- a/dbms/src/TableFunctions/getStructureOfRemoteTable.cpp +++ b/dbms/src/TableFunctions/getStructureOfRemoteTable.cpp @@ -17,7 +17,7 @@ namespace ErrorCodes } -NamesAndTypes getStructureOfRemoteTable( +NamesAndTypesList getStructureOfRemoteTable( const Cluster & cluster, const std::string & database, const std::string & table, @@ -25,7 +25,7 @@ NamesAndTypes getStructureOfRemoteTable( { /// Request for a table description String query = "DESC TABLE " + backQuoteIfNeed(database) + "." + backQuoteIfNeed(table); - NamesAndTypes res; + NamesAndTypesList res; /// Send to the first any remote shard. const auto & shard_info = cluster.getAnyShardInfo(); diff --git a/dbms/src/TableFunctions/getStructureOfRemoteTable.h b/dbms/src/TableFunctions/getStructureOfRemoteTable.h index 221a085ebe3..70b3d83b8f1 100644 --- a/dbms/src/TableFunctions/getStructureOfRemoteTable.h +++ b/dbms/src/TableFunctions/getStructureOfRemoteTable.h @@ -11,7 +11,7 @@ class Context; /// Find the names and types of the table columns on any server in the cluster. /// Used to implement the `remote` table function and others. -NamesAndTypes getStructureOfRemoteTable( +NamesAndTypesList getStructureOfRemoteTable( const Cluster & cluster, const std::string & database, const std::string & table,