mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Revert "Removed questionable code (2) [#CLICKHOUSE-2]."
This reverts commit fcabe8b888
.
This commit is contained in:
parent
827e82efa6
commit
ec71908b00
@ -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);
|
||||
|
@ -20,6 +20,7 @@ private:
|
||||
using ExpressionActionsPtr = std::shared_ptr<ExpressionActions>;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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<StringRef, const DataTypePtr *, StringRefHash> 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);
|
||||
|
@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <initializer_list>
|
||||
|
||||
#include <DataTypes/IDataType.h>
|
||||
@ -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<NameAndType>
|
||||
using NamesAndTypes = std::vector<NameAndTypePair>;
|
||||
|
||||
class NamesAndTypesList : public std::list<NameAndTypePair>
|
||||
{
|
||||
public:
|
||||
NamesAndTypes() {}
|
||||
NamesAndTypesList() {}
|
||||
|
||||
NamesAndTypes(std::initializer_list<NameAndType> init) : std::vector<NameAndType>(init) {}
|
||||
NamesAndTypesList(std::initializer_list<NameAndTypePair> init) : std::list<NameAndTypePair>(init) {}
|
||||
|
||||
template <typename Iterator>
|
||||
NamesAndTypes(Iterator begin, Iterator end) : std::vector<NameAndType>(begin, end) {}
|
||||
NamesAndTypesList(Iterator begin, Iterator end) : std::list<NameAndTypePair>(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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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());
|
||||
|
||||
|
@ -35,7 +35,7 @@ try
|
||||
|
||||
Context context = Context::createGlobal();
|
||||
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionActionsChain chain;
|
||||
analyzer.appendSelect(chain, false);
|
||||
analyzer.appendProjectResult(chain);
|
||||
|
@ -41,7 +41,7 @@ try
|
||||
|
||||
Context context = Context::createGlobal();
|
||||
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionActionsChain chain;
|
||||
analyzer.appendSelect(chain, false);
|
||||
analyzer.appendProjectResult(chain);
|
||||
|
@ -33,7 +33,7 @@ int main(int, char **)
|
||||
|
||||
try
|
||||
{
|
||||
NamesAndTypes names_and_types_list
|
||||
NamesAndTypesList names_and_types_list
|
||||
{
|
||||
{"WatchID", std::make_shared<DataTypeUInt64>()},
|
||||
{"JavaEnable", std::make_shared<DataTypeUInt8>()},
|
||||
@ -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
|
||||
|
@ -58,7 +58,7 @@ try
|
||||
|
||||
Context context = Context::createGlobal();
|
||||
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndType("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionAnalyzer analyzer(ast, context, {}, {NameAndTypePair("number", std::make_shared<DataTypeUInt64>())});
|
||||
ExpressionActionsChain chain;
|
||||
analyzer.appendSelect(chain, false);
|
||||
analyzer.appendProjectResult(chain);
|
||||
|
@ -28,7 +28,7 @@ try
|
||||
{
|
||||
using namespace DB;
|
||||
|
||||
NamesAndTypes names_and_types_list
|
||||
NamesAndTypesList names_and_types_list
|
||||
{
|
||||
{"WatchID", std::make_shared<DataTypeUInt64>()},
|
||||
{"JavaEnable", std::make_shared<DataTypeUInt8>()},
|
||||
@ -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
|
||||
|
@ -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<DataTypeUInt64>()},
|
||||
{"JavaEnable", std::make_shared<DataTypeUInt8>()},
|
||||
@ -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
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <string.h>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <Common/typeid_cast.h>
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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 &)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 &)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -6,9 +6,6 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include <Core/Types.h>
|
||||
#include <Core/NamesAndTypes.h>
|
||||
|
@ -133,7 +133,7 @@ ExpressionAction ExpressionAction::arrayJoin(const NameSet & array_joined_column
|
||||
return a;
|
||||
}
|
||||
|
||||
ExpressionAction ExpressionAction::ordinaryJoin(std::shared_ptr<const Join> join_, const NamesAndTypes & columns_added_by_join_)
|
||||
ExpressionAction ExpressionAction::ordinaryJoin(std::shared_ptr<const Join> 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<size_t> 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();
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
/// For JOIN
|
||||
std::shared_ptr<const Join> 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<const Join> join_, const NamesAndTypes & columns_added_by_join_);
|
||||
static ExpressionAction ordinaryJoin(std::shared_ptr<const Join> 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<ExpressionAction>;
|
||||
|
||||
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;
|
||||
|
@ -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<String> 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<const DataTypeExpression *>(argument_types[i].get());
|
||||
ASTFunction * lambda_args_tuple = typeid_cast<ASTFunction *>(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<ExpressionActions>(NamesAndTypes(), settings);
|
||||
ExpressionActionsPtr actions = std::make_shared<ExpressionActions>(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;
|
||||
|
@ -1,10 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
|
||||
#include <Interpreters/AggregateDescription.h>
|
||||
#include <Interpreters/Settings.h>
|
||||
#include <Core/Block.h>
|
||||
@ -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<String, ASTPtr>;
|
||||
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;
|
||||
|
@ -161,17 +161,17 @@ BlockIO InterpreterCreateQuery::createDatabase(ASTCreateQuery & create)
|
||||
}
|
||||
|
||||
|
||||
using ColumnsAndDefaults = std::pair<NamesAndTypes, ColumnDefaults>;
|
||||
using ColumnsAndDefaults = std::pair<NamesAndTypesList, ColumnDefaults>;
|
||||
|
||||
/// 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<std::pair<NameAndType *, ASTColumnDeclaration *>> defaulted_columns{};
|
||||
std::vector<std::pair<NameAndTypePair *, ASTColumnDeclaration *>> 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<ASTExpressionList>();
|
||||
|
||||
@ -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<ASTExpressionList>();
|
||||
@ -393,7 +393,7 @@ InterpreterCreateQuery::ColumnsInfo InterpreterCreateQuery::setColumns(
|
||||
|
||||
/// Check for duplicates
|
||||
std::set<String> 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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -57,14 +57,14 @@ BlockInputStreamPtr InterpreterDescribeQuery::executeImpl()
|
||||
{
|
||||
const ASTDescribeQuery & ast = typeid_cast<const ASTDescribeQuery &>(*query_ptr);
|
||||
|
||||
NamesAndTypes columns;
|
||||
NamesAndTypesList columns;
|
||||
ColumnDefaults column_defaults;
|
||||
StoragePtr table;
|
||||
|
||||
auto table_expression = typeid_cast<const ASTTableExpression *>(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)
|
||||
|
@ -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;
|
||||
|
@ -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<ASTSelectQuery &>(*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);
|
||||
|
||||
|
@ -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<ExpressionAnalyzer> 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;
|
||||
|
@ -328,7 +328,7 @@ void SystemLog<LogElement>::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(
|
||||
|
@ -25,7 +25,7 @@ namespace ErrorCodes
|
||||
std::pair<Field, std::shared_ptr<const IDataType>> evaluateConstantExpression(const ASTPtr & node, const Context & context)
|
||||
{
|
||||
ExpressionActionsPtr expr_for_constant_folding = ExpressionAnalyzer(
|
||||
node, context, nullptr, NamesAndTypes{{ "_dummy", std::make_shared<DataTypeUInt8>() }}).getConstActions();
|
||||
node, context, nullptr, NamesAndTypesList{{ "_dummy", std::make_shared<DataTypeUInt8>() }}).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<DataTypeUInt8>(), "_dummy" }};
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<std::string, ColumnDefault> & column_defaults,
|
||||
const Context & context);
|
||||
|
||||
|
@ -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<DataTypeInt16>()},
|
||||
{"s1", std::make_shared<DataTypeString>()},
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<std::pair<NameAndType, AlterCommand *>> defaulted_columns{};
|
||||
std::vector<std::pair<NameAndTypePair, AlterCommand *>> defaulted_columns{};
|
||||
|
||||
auto default_expr_list = std::make_shared<ASTExpressionList>();
|
||||
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);
|
||||
|
@ -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<AlterCommand>
|
||||
{
|
||||
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);
|
||||
|
@ -29,7 +29,7 @@ String ColumnsDescription<store>::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)
|
||||
{
|
||||
|
@ -14,9 +14,9 @@ struct ColumnsDescription
|
||||
template <typename T>
|
||||
using by_value_or_cref = std::conditional_t<store, T, const T &>;
|
||||
|
||||
by_value_or_cref<NamesAndTypes> columns;
|
||||
by_value_or_cref<NamesAndTypes> materialized;
|
||||
by_value_or_cref<NamesAndTypes> alias;
|
||||
by_value_or_cref<NamesAndTypesList> columns;
|
||||
by_value_or_cref<NamesAndTypesList> materialized;
|
||||
by_value_or_cref<NamesAndTypesList> alias;
|
||||
by_value_or_cref<ColumnDefaults> defaults;
|
||||
|
||||
String toString() const;
|
||||
|
@ -24,9 +24,9 @@ namespace ErrorCodes
|
||||
}
|
||||
|
||||
|
||||
NamesAndTypes ITableDeclaration::getColumnsList() const
|
||||
NamesAndTypesList ITableDeclaration::getColumnsList() const
|
||||
{
|
||||
return ext::collection_cast<NamesAndTypes>(getColumnsListRange());
|
||||
return ext::collection_cast<NamesAndTypesList>(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 <typename Arg, typename... Args>
|
||||
static NamesAndTypesMap & getColumnsMapImpl(NamesAndTypesMap & res, const Arg & arg, const Args &... args)
|
||||
{
|
||||
static_assert(std::is_same_v<Arg, NamesAndTypes>, "getColumnsMap requires arguments of type NamesAndTypes");
|
||||
static_assert(std::is_same_v<Arg, NamesAndTypesList>, "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<StringRef, StringRefHash>;
|
||||
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<String>;
|
||||
@ -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);
|
||||
|
@ -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<const NamesAndTypes, const NamesAndTypes>;
|
||||
using ColumnsListRange = boost::range::joined_range<const NamesAndTypesList, const NamesAndTypesList>;
|
||||
/// Returns a lazily joined range of table's ordinary and materialized columns, without unnecessary copying
|
||||
ColumnsListRange getColumnsListRange() const;
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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},
|
||||
|
@ -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();
|
||||
|
@ -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<ExpressionActions>(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<String, const IDataType *>;
|
||||
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<String, size_t> 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<ExpressionActions>(NamesAndTypes(), context.getSettingsRef());
|
||||
out_expression = std::make_shared<ExpressionActions>(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)
|
||||
{
|
||||
|
@ -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<std::mutex> 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<DataTypeString>());
|
||||
return NameAndTypePair("_part", std::make_shared<DataTypeString>());
|
||||
if (column_name == "_part_index")
|
||||
return NameAndType("_part_index", std::make_shared<DataTypeUInt64>());
|
||||
return NameAndTypePair("_part_index", std::make_shared<DataTypeUInt64>());
|
||||
if (column_name == "_sample_factor")
|
||||
return NameAndType("_sample_factor", std::make_shared<DataTypeFloat64>());
|
||||
return NameAndTypePair("_sample_factor", std::make_shared<DataTypeFloat64>());
|
||||
|
||||
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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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<std::shared_mutex> 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<size_t> marks_size;
|
||||
for (const NameAndType & name_type : columns)
|
||||
for (const NameAndTypePair & name_type : columns)
|
||||
{
|
||||
name_type.type->enumerateStreams([&](const IDataType::SubstreamPath & substream_path)
|
||||
{
|
||||
|
@ -248,7 +248,7 @@ struct MergeTreeDataPart
|
||||
Checksums checksums;
|
||||
|
||||
/// Columns description.
|
||||
NamesAndTypes columns;
|
||||
NamesAndTypesList columns;
|
||||
|
||||
using ColumnToSize = std::map<std::string, size_t>;
|
||||
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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();
|
||||
|
@ -94,8 +94,8 @@ private:
|
||||
bool do_not_steal_tasks;
|
||||
bool predict_block_size_bytes;
|
||||
std::vector<NameSet> per_part_column_name_set;
|
||||
std::vector<NamesAndTypes> per_part_columns;
|
||||
std::vector<NamesAndTypes> per_part_pre_columns;
|
||||
std::vector<NamesAndTypesList> per_part_columns;
|
||||
std::vector<NamesAndTypesList> 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<char> per_part_remove_prewhere_column;
|
||||
std::vector<char> per_part_should_reorder;
|
||||
|
@ -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);
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
using ValueSizeMap = std::map<std::string, double>;
|
||||
|
||||
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;
|
||||
|
@ -42,7 +42,7 @@ MergeTreeWhereOptimizer::MergeTreeWhereOptimizer(
|
||||
: primary_key_columns{ext::map<std::unordered_set>(data.getSortDescription(),
|
||||
[] (const SortColumnDescription & col) { return col.column_name; })},
|
||||
table_columns{ext::map<std::unordered_set>(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}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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<std::string, bool(*)(RPNElement & out, const Field & value, const ASTPtr & node)>;
|
||||
static const AtomMap atom_map;
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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_,
|
||||
|
@ -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_,
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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<DataTypeUInt64>());
|
||||
@ -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<NameAndType> namesAndTypesSet(dictionary_names_and_types.begin(), dictionary_names_and_types.end());
|
||||
std::set<NameAndTypePair> namesAndTypesSet(dictionary_names_and_types.begin(), dictionary_names_and_types.end());
|
||||
|
||||
for (auto & column : columns)
|
||||
{
|
||||
|
@ -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<IDictionaryBase>::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_);
|
||||
|
@ -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 };
|
||||
|
@ -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_,
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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_),
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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_);
|
||||
};
|
||||
|
||||
|
@ -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_)
|
||||
|
@ -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_);
|
||||
|
@ -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_},
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ class StorageMaterializedView : public ext::shared_ptr_helper<StorageMaterialize
|
||||
public:
|
||||
std::string getName() const override { return "MaterializedView"; }
|
||||
std::string getTableName() const override { return table_name; }
|
||||
const NamesAndTypes & getColumnsListImpl() const override { return columns; }
|
||||
const NamesAndTypesList & getColumnsListImpl() const override { return columns; }
|
||||
ASTPtr getInnerQuery() const { return inner_query->clone(); };
|
||||
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_);
|
||||
};
|
||||
|
@ -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_)
|
||||
|
@ -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_);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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_,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user