From c891f89505e34489001f4ab07077490dc3cd3cb6 Mon Sep 17 00:00:00 2001 From: Murphy Date: Wed, 27 Nov 2024 14:10:06 +0800 Subject: [PATCH] give up null partitions Signed-off-by: Murphy --- .../PartitionColumnMinMaxRewriteRule.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/transformation/PartitionColumnMinMaxRewriteRule.java b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/transformation/PartitionColumnMinMaxRewriteRule.java index 8bd038fe21f85..3d080ff9370ad 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/transformation/PartitionColumnMinMaxRewriteRule.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rule/transformation/PartitionColumnMinMaxRewriteRule.java @@ -226,10 +226,15 @@ private OptExpression optimizeWithPartitionPrune(OptExpression optExpression, if (hasMinMax.first) { List sorted = partitionInfo.getSortedPartitions(true); sorted.retainAll(nonEmptyPartitionIds); - sorted.removeAll(nullPartitions); if (CollectionUtils.isEmpty(sorted)) { return null; } + // TODO: in theory if we can confirm one partition contains only NULL values, we can rule out these + // partitions from sorted. But currently a range-partition can contains both NULL value and regular + // values + if (nullPartitions.contains(sorted.get(0))) { + return null; + } pruned.add(sorted.get(0)); } @@ -240,6 +245,9 @@ private OptExpression optimizeWithPartitionPrune(OptExpression optExpression, if (CollectionUtils.isEmpty(sorted)) { return null; } + if (nullPartitions.contains(sorted.get(0))) { + return null; + } pruned.add(sorted.get(0)); }