mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Revert "Addition to prev. revision [#CLICKHOUSE-2]"
This reverts commit bc4a5794d9
.
This commit is contained in:
parent
798299ba89
commit
0fa9383d3e
@ -33,7 +33,12 @@ struct NameAndType
|
||||
class NamesAndTypes : public std::vector<NameAndType>
|
||||
{
|
||||
public:
|
||||
using std::vector<NameAndType>::vector;
|
||||
NamesAndTypes() {}
|
||||
|
||||
NamesAndTypes(std::initializer_list<NameAndType> init) : std::vector<NameAndType>(init) {}
|
||||
|
||||
template <typename Iterator>
|
||||
NamesAndTypes(Iterator begin, Iterator end) : std::vector<NameAndType>(begin, end) {}
|
||||
|
||||
void readText(ReadBuffer & buf);
|
||||
void writeText(WriteBuffer & buf) const;
|
||||
|
@ -757,8 +757,11 @@ void ExpressionActions::finalize(const Names & output_columns)
|
||||
/// Which columns nobody will touch from the current action to the last.
|
||||
NameSet unmodified_columns;
|
||||
|
||||
for (const auto & name_type : sample_block.getNamesAndTypes())
|
||||
unmodified_columns.insert(name_type.name);
|
||||
{
|
||||
NamesAndTypes sample_columns = sample_block.getNamesAndTypes();
|
||||
for (NamesAndTypes::iterator it = sample_columns.begin(); it != sample_columns.end(); ++it)
|
||||
unmodified_columns.insert(it->name);
|
||||
}
|
||||
|
||||
/// Let's go from the end and maintain set of required columns at this stage.
|
||||
/// We will throw out unnecessary actions, although usually they are absent by construction.
|
||||
@ -853,18 +856,17 @@ void ExpressionActions::finalize(const Names & output_columns)
|
||||
if (final_columns.empty())
|
||||
final_columns.insert(getSmallestColumn(input_columns));
|
||||
|
||||
NamesAndTypes input_columns_filtered;
|
||||
for (const auto & name_type : input_columns)
|
||||
for (NamesAndTypes::iterator it = input_columns.begin(); it != input_columns.end();)
|
||||
{
|
||||
if (needed_columns.count(name_type.name))
|
||||
input_columns_filtered.push_back(name_type);
|
||||
else
|
||||
NamesAndTypes::iterator it0 = it;
|
||||
++it;
|
||||
if (!needed_columns.count(it0->name))
|
||||
{
|
||||
if (unmodified_columns.count(name_type.name))
|
||||
sample_block.erase(name_type.name);
|
||||
if (unmodified_columns.count(it0->name))
|
||||
sample_block.erase(it0->name);
|
||||
input_columns.erase(it0);
|
||||
}
|
||||
}
|
||||
input_columns = std::move(input_columns_filtered);
|
||||
|
||||
/* std::cerr << "\n";
|
||||
for (const auto & action : actions)
|
||||
|
@ -139,11 +139,13 @@ bool functionIsInOrGlobalInOperator(const String & name)
|
||||
void removeDuplicateColumns(NamesAndTypes & columns)
|
||||
{
|
||||
std::set<String> names;
|
||||
NamesAndTypes filtered(columns.size());
|
||||
for (auto & name_type : columns)
|
||||
if (names.emplace(name_type.name).second)
|
||||
filtered.push_back(std::move(name_type));
|
||||
columns = std::move(filtered);
|
||||
for (auto it = columns.begin(); it != columns.end();)
|
||||
{
|
||||
if (names.emplace(it->name).second)
|
||||
++it;
|
||||
else
|
||||
columns.erase(it++);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -2737,9 +2739,13 @@ void ExpressionAnalyzer::collectUsedColumns()
|
||||
NameSet required_joined_columns;
|
||||
getRequiredColumnsImpl(ast, available_columns, required, ignored, available_joined_columns, required_joined_columns);
|
||||
|
||||
columns_added_by_join.erase(std::remove_if(columns_added_by_join.begin(), columns_added_by_join.end(),
|
||||
[&required_joined_columns] (const auto & name_type) { return !required_joined_columns.count(name_type.name); }),
|
||||
columns_added_by_join.end());
|
||||
for (NamesAndTypes::iterator it = columns_added_by_join.begin(); it != columns_added_by_join.end();)
|
||||
{
|
||||
if (required_joined_columns.count(it->name))
|
||||
++it;
|
||||
else
|
||||
columns_added_by_join.erase(it++);
|
||||
}
|
||||
|
||||
/// Insert the columns required for the ARRAY JOIN calculation into the required columns list.
|
||||
NameSet array_join_sources;
|
||||
@ -2756,14 +2762,15 @@ void ExpressionAnalyzer::collectUsedColumns()
|
||||
|
||||
unknown_required_columns = required;
|
||||
|
||||
NamesAndTypes filtered_columns;
|
||||
for (const auto & name_type : columns)
|
||||
for (NamesAndTypes::iterator it = columns.begin(); it != columns.end();)
|
||||
{
|
||||
unknown_required_columns.erase(name_type.name);
|
||||
if (required.count(name_type.name))
|
||||
filtered_columns.push_back(name_type);
|
||||
unknown_required_columns.erase(it->name);
|
||||
|
||||
if (!required.count(it->name))
|
||||
columns.erase(it++);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
columns = std::move(filtered_columns);
|
||||
|
||||
/// Perhaps, there are virtual columns among the unknown columns. Remove them from the list of unknown and add
|
||||
/// in columns list, so that when further processing the request they are perceived as real.
|
||||
|
Loading…
Reference in New Issue
Block a user