[fix](nereids)filter estimation for slot=unknown #39592 (#39933)

## Proposed changes
pick #39592
Issue Number: close #xxx

<!--Describe your changes.-->
This commit is contained in:
minghong
2024-08-27 08:03:00 +08:00
committed by GitHub
parent a5c8ed1cde
commit aacd61a98f
2 changed files with 95 additions and 6 deletions

View File

@ -334,14 +334,28 @@ public class FilterEstimation extends ExpressionVisitor<Statistics, EstimationCo
ColumnStatistic statsForRight,
EstimationContext context) {
double selectivity;
double ndv = statsForLeft.ndv;
double val = statsForRight.maxValue;
if (val > statsForLeft.maxValue || val < statsForLeft.minValue) {
selectivity = 0.0;
if (statsForLeft.isUnKnown) {
selectivity = DEFAULT_INEQUALITY_COEFFICIENT;
} else {
selectivity = StatsMathUtil.minNonNaN(1.0, 1.0 / ndv);
double ndv = statsForLeft.ndv;
if (statsForRight.isUnKnown) {
if (ndv >= 1.0) {
selectivity = 1.0 / ndv;
} else {
selectivity = DEFAULT_INEQUALITY_COEFFICIENT;
}
} else {
double val = statsForRight.maxValue;
if (val > statsForLeft.maxValue || val < statsForLeft.minValue) {
selectivity = 0.0;
} else if (ndv >= 1.0) {
selectivity = StatsMathUtil.minNonNaN(1.0, 1.0 / ndv);
} else {
selectivity = DEFAULT_INEQUALITY_COEFFICIENT;
}
selectivity = getNotNullSelectivity(statsForLeft, selectivity);
}
}
selectivity = getNotNullSelectivity(statsForLeft, selectivity);
Statistics equalStats = context.statistics.withSel(selectivity);
Expression left = cp.left();
equalStats.addColumnStats(left, statsForRight);