mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #38946 from amosbird/nullable-partition-fix1
Fix incorrect partition pruning when there is a nullable partition
This commit is contained in:
commit
d0db7135cb
@ -15,9 +15,21 @@ bool PartitionPruner::canBePruned(const DataPart & part)
|
||||
{
|
||||
const auto & partition_value = part.partition.value;
|
||||
std::vector<FieldRef> index_value(partition_value.begin(), partition_value.end());
|
||||
for (auto & field : index_value)
|
||||
{
|
||||
// NULL_LAST
|
||||
if (field.isNull())
|
||||
field = POSITIVE_INFINITY;
|
||||
}
|
||||
is_valid = partition_condition.mayBeTrueInRange(
|
||||
partition_value.size(), index_value.data(), index_value.data(), partition_key.data_types);
|
||||
partition_filter_map.emplace(partition_id, is_valid);
|
||||
if (!is_valid)
|
||||
{
|
||||
WriteBufferFromOwnString buf;
|
||||
part.partition.serializeText(part.storage, buf, FormatSettings{});
|
||||
LOG_TRACE(&Poco::Logger::get("PartitionPruner"), "Partition {} gets pruned", buf.str());
|
||||
}
|
||||
}
|
||||
return !is_valid;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
\N
|
@ -0,0 +1,9 @@
|
||||
drop table if exists n;
|
||||
|
||||
create table n(nc Nullable(int)) engine = MergeTree order by (tuple()) partition by (nc) settings allow_nullable_key = 1;
|
||||
|
||||
insert into n values (null);
|
||||
|
||||
select * from n where nc is null;
|
||||
|
||||
drop table n;
|
Loading…
Reference in New Issue
Block a user