Skip to content

Commit

Permalink
stats derive for min()/max() agg function
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Aug 29, 2024
1 parent d7eb343 commit f15d57c
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,9 @@ public ColumnStatistic visitMin(Min min, Statistics context) {
if (columnStat.isUnKnown) {
return ColumnStatistic.UNKNOWN;
}
/*
we keep columnStat.min and columnStat.max, but set ndv=1.
if there is group-by keys, we will update count when visiting group clause
*/
double width = min.child().getDataType().width();
return new ColumnStatisticBuilder().setCount(1).setNdv(1).setAvgSizeByte(width)
.setMinValue(columnStat.minValue).setMinExpr(columnStat.minExpr)
.setMaxValue(columnStat.maxValue).setMaxExpr(columnStat.maxExpr).build();
// if this is scalar agg, we will update count and ndv to 1 when visiting group clause
return new ColumnStatisticBuilder(columnStat)
.build();
}

@Override
Expand All @@ -359,14 +354,8 @@ public ColumnStatistic visitMax(Max max, Statistics context) {
if (columnStat.isUnKnown) {
return ColumnStatistic.UNKNOWN;
}
/*
we keep columnStat.min and columnStat.max, but set ndv=1.
if there is group-by keys, we will update count when visiting group clause
*/
int width = max.child().getDataType().width();
return new ColumnStatisticBuilder().setCount(1D).setNdv(1D).setAvgSizeByte(width)
.setMinValue(columnStat.minValue).setMinExpr(columnStat.minExpr)
.setMaxValue(columnStat.maxValue).setMaxExpr(columnStat.maxExpr)
// if this is scalar agg, we will update count and ndv to 1 when visiting group clause
return new ColumnStatisticBuilder(columnStat)
.build();
}

Expand Down

0 comments on commit f15d57c

Please sign in to comment.