Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Sep 27, 2023
1 parent fd47209 commit 363689e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public FilterEstimation(Set<Slot> aggSlots) {
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.
return expression.accept(this, new EstimationContext(statistics));
Statistics stats = expression.accept(this, new EstimationContext(statistics));
stats.enforceValid();
return stats;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void test1() {
Statistics stat = new Statistics(1000, slotToColumnStat);
FilterEstimation filterEstimation = new FilterEstimation();
Statistics expected = filterEstimation.estimate(or, stat);
Assertions.assertEquals(51, expected.getRowCount(), 0.1);
Assertions.assertEquals(51.9, expected.getRowCount(), 0.1);
}

// a > 500 and b < 100 or a > c
Expand Down Expand Up @@ -503,7 +503,7 @@ public void test12() {
* filter range has intersection with (c.min, c.max)
* rows = 100
* a primary key, a.ndv reduced by 1/4
* b normal field, b.ndv=20 =>
* b normal field, b.ndv=20
* c.ndv = 10/40 * c.ndv
*/
@Test
Expand Down Expand Up @@ -550,7 +550,7 @@ public void testFilterInsideMinMax() {
Assertions.assertEquals(100, statsA.maxValue);

ColumnStatistic statsB = estimated.findColumnStatistics(b);
Assertions.assertEquals(15.6, statsB.ndv, 0.1);
Assertions.assertEquals(20, statsB.ndv, 0.1);
Assertions.assertEquals(0, statsB.minValue);
Assertions.assertEquals(500, statsB.maxValue);

Expand Down Expand Up @@ -679,7 +679,7 @@ public void testInPredicateEstimationForColumns() {
Assertions.assertEquals(5, statsA.ndv, 0.1);
Assertions.assertEquals(0, statsA.minValue);
Assertions.assertEquals(100, statsA.maxValue);
Assertions.assertEquals(4.5, statsB.ndv, 0.1);
Assertions.assertEquals(5, statsB.ndv, 0.1);
Assertions.assertEquals(0, statsB.minValue);
Assertions.assertEquals(500, statsB.maxValue);
Assertions.assertEquals(2, statsC.ndv);
Expand Down Expand Up @@ -753,7 +753,7 @@ public void testInPredicateEstimationForColumnsOutofRange() {
Assertions.assertEquals(5, statsA.ndv, 0.1);
Assertions.assertEquals(0, statsA.minValue);
Assertions.assertEquals(100, statsA.maxValue);
Assertions.assertEquals(4.5, statsB.ndv, 0.1);
Assertions.assertEquals(5, statsB.ndv, 0.1);
Assertions.assertEquals(0, statsB.minValue);
Assertions.assertEquals(500, statsB.maxValue);
Assertions.assertEquals(2, statsC.ndv);
Expand Down Expand Up @@ -819,7 +819,7 @@ public void testFilterEstimationForColumnsNotChanged() {
Assertions.assertEquals(75, statsA.ndv);
Assertions.assertEquals(0, statsA.minValue);
Assertions.assertEquals(100, statsA.maxValue);
Assertions.assertEquals(19.9, statsB.ndv, 0.1);
Assertions.assertEquals(20, statsB.ndv, 0.1);
Assertions.assertEquals(0, statsB.minValue);
Assertions.assertEquals(500, statsB.maxValue);
Assertions.assertEquals(30, statsC.ndv);
Expand Down

0 comments on commit 363689e

Please sign in to comment.