diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticRange.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticRange.java index 7b7b08ab24669de..e314ad895d2bc79 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticRange.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticRange.java @@ -86,9 +86,9 @@ public double overlapPercentWith(StatisticRange other) { double lengthOfIntersect = dataType.rangeLength(Math.min(this.high, other.high), Math.max(this.low, other.low)); if (Double.isInfinite(lengthOfIntersect)) { - if (Double.isFinite(this.distinctValues) && Double.isFinite(other.distinctValues)) { - return Math.min(other.distinctValues / this.distinctValues, 1); - } + // if (Double.isFinite(this.distinctValues) && Double.isFinite(other.distinctValues)) { + // return Math.min(other.distinctValues / this.distinctValues, 1); + // } return INFINITE_TO_INFINITE_RANGE_INTERSECT_OVERLAP_HEURISTIC_FACTOR; } if (lengthOfIntersect == 0) { diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/FilterEstimationTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/FilterEstimationTest.java index d7c44e082cf52e3..79ecb4235b5ce0f 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/FilterEstimationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/stats/FilterEstimationTest.java @@ -1365,4 +1365,33 @@ public void testStringRangeColToCol() { Statistics agrtc = new FilterEstimation().estimate(new GreaterThan(a, c), baseStats); Assertions.assertEquals(50, agrtc.getRowCount()); } + + @Test + void testAndWithInfinite() { + SlotReference a = new SlotReference("a", new VarcharType(25)); + ColumnStatisticBuilder columnStatisticBuilderA = new ColumnStatisticBuilder() + .setNdv(233) + .setAvgSizeByte(4) + .setNumNulls(0) + .setCount(133493073); + + SlotReference b = new SlotReference("b", new VarcharType(25)); + ColumnStatisticBuilder columnStatisticBuilderB = new ColumnStatisticBuilder() + .setNdv(488) + .setAvgSizeByte(25) + .setNumNulls(0) + .setCount(133493073); + StatisticsBuilder statsBuilder = new StatisticsBuilder(); + statsBuilder.setRowCount(133493073); + statsBuilder.putColumnStatistics(a, columnStatisticBuilderA.build()); + statsBuilder.putColumnStatistics(b, columnStatisticBuilderB.build()); + + Expression predicate = new And( + new GreaterThanEqual(a, new org.apache.doris.nereids.trees.expressions.literal.StringLiteral("2024-05-14")), + new GreaterThan(b, new IntegerLiteral(0)) + ); + + Statistics stats = new FilterEstimation().estimate(predicate, statsBuilder.build()); + System.out.println(stats); + } }