Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public Statistics estimate(Expression expression, Statistics statistics) {
// For a comparison predicate, only when it's left side is a slot and right side is a literal, we would
// consider is a valid predicate.
Statistics stats = expression.accept(this, new EstimationContext(statistics));
if (stats.getRowCount() <= 0) {
stats = new StatisticsBuilder(stats).setRowCount(1).build();
}
stats.enforceValid();
return stats;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public void test7() {
Statistics stat = new Statistics(1000, slotToColumnStat);
FilterEstimation filterEstimation = new FilterEstimation();
Statistics expected = filterEstimation.estimate(ge, stat);
Assertions.assertEquals(0, expected.getRowCount());
Assertions.assertEquals(1, expected.getRowCount());
}

// a < b
Expand Down Expand Up @@ -611,9 +611,9 @@ public void testFilterOutofMinMax() {
FilterEstimation filterEstimation = new FilterEstimation();
Statistics estimated = filterEstimation.estimate(ge, stat);
ColumnStatistic statsA = estimated.findColumnStatistics(a);
Assertions.assertEquals(0, statsA.ndv);
Assertions.assertEquals(1, statsA.ndv);
ColumnStatistic statsB = estimated.findColumnStatistics(b);
Assertions.assertEquals(0, statsB.ndv);
Assertions.assertEquals(1, statsB.ndv);
ColumnStatistic statsC = estimated.findColumnStatistics(c);
Assertions.assertEquals(0, statsC.ndv);
Assertions.assertTrue(Double.isInfinite(statsC.minValue));
Expand Down Expand Up @@ -1251,7 +1251,7 @@ public void testStringRangeColToCol() {
Assertions.assertEquals(100, agrtb.getRowCount());
// (2020-2022) < (2010,2012), sel=0
Statistics alessb = new FilterEstimation().estimate(new LessThan(a, b), baseStats);
Assertions.assertEquals(0, alessb.getRowCount());
Assertions.assertEquals(1, alessb.getRowCount());

// (2020-2022) > (2010-2021), sel = DEFAULT (0.5)
Statistics agrtc = new FilterEstimation().estimate(new GreaterThan(a, c), baseStats);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ public void testFilterOutofRange() {
Group ownerGroup = new Group(null, groupExpression, null);
groupExpression.setOwnerGroup(ownerGroup);
StatsCalculator.estimate(groupExpression, null);
Assertions.assertEquals(0, ownerGroup.getStatistics().getRowCount(), 0.001);
Assertions.assertEquals(1, ownerGroup.getStatistics().getRowCount(), 0.001);

LogicalFilter<GroupPlan> logicalFilterOr = new LogicalFilter<>(or, groupPlan);
GroupExpression groupExpressionOr = new GroupExpression(logicalFilterOr, ImmutableList.of(childGroup));
Group ownerGroupOr = new Group(null, groupExpressionOr, null);
groupExpressionOr.setOwnerGroup(ownerGroupOr);
StatsCalculator.estimate(groupExpressionOr, null);
Assertions.assertEquals(0, ownerGroupOr.getStatistics().getRowCount(), 0.001);
Assertions.assertEquals(1, ownerGroupOr.getStatistics().getRowCount(), 0.001);
}
// TODO: temporary disable this test, until we could get column stats
// @Test
Expand Down