Nullable partition pruning fix

This commit is contained in:
Amos Bird 2022-07-07 16:02:38 +08:00
parent e8a5327625
commit 19bd3d8d9f
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 22 additions and 0 deletions

View File

@ -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;
}

View File

@ -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;