mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Properly check distinct columns.
This commit is contained in:
parent
42399e8866
commit
4c09880bc4
@ -8,16 +8,16 @@ namespace DB
|
||||
|
||||
static bool checkColumnsAlreadyDistinct(const Names & columns, const NameSet & distinct_names)
|
||||
{
|
||||
bool columns_already_distinct = true;
|
||||
if (columns.size() != distinct_names.size()) {
|
||||
columns_already_distinct = false;
|
||||
} else {
|
||||
for (const auto & name : columns)
|
||||
if (distinct_names.count(name) == 0)
|
||||
columns_already_distinct = false;
|
||||
}
|
||||
if (distinct_names.empty())
|
||||
return false;
|
||||
|
||||
return columns_already_distinct;
|
||||
/// Now we need to check that distinct_names is a subset of columns.
|
||||
std::unordered_set<std::string_view> columns_set(columns.begin(), columns.end());
|
||||
for (const auto & name : distinct_names)
|
||||
if (columns_set.count(name) == 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static ITransformingStep::Traits getTraits(bool pre_distinct, bool already_distinct_columns)
|
||||
|
Loading…
Reference in New Issue
Block a user