[Fix](statistics)Fix alter column stats data size is always 0 bug (#24891)

Fix alter column stats data size is always 0 bug.
This commit is contained in:
Jibing-Li
2023-10-09 15:48:11 +08:00
committed by GitHub
parent 0bf954ba05
commit 7ceb029a17
4 changed files with 13 additions and 6 deletions

View File

@ -190,7 +190,7 @@ public class ColumnStatisticBuilder {
}
public ColumnStatistic build() {
dataSize = Math.max((count - numNulls + 1) * avgSizeByte, 0);
dataSize = dataSize > 0 ? dataSize : Math.max((count - numNulls + 1) * avgSizeByte, 0);
if (original == null && !isUnknown) {
original = new ColumnStatistic(count, ndv, null, avgSizeByte, numNulls,
dataSize, minValue, maxValue, minExpr, maxExpr,

View File

@ -248,7 +248,14 @@ public class StatisticsRepository {
builder.setMaxValue(StatisticsUtil.convertToDouble(column.getType(), max));
}
if (dataSize != null) {
builder.setDataSize(Double.parseDouble(dataSize));
double size = Double.parseDouble(dataSize);
double rows = Double.parseDouble(rowCount);
if (size > 0) {
builder.setDataSize(size);
if (rows > 0) {
builder.setAvgSizeByte(size / rows);
}
}
}
ColumnStatistic columnStatistic = builder.build();