Extract isSingleValue(Expression) to simplify code
@@ -229,10 +229,10 @@ public class FilterStatsCalculator
if (!(node.getValue() instanceof SymbolReference)) {
return visitExpression(node, context);
}
- if (!(node.getMin() instanceof Literal || isSingleValue(getExpressionStats(node.getMin())))) {
+ if (!isSingleValue(node.getMin())) {
return visitExpression(node, context);
}
- if (!(node.getMax() instanceof Literal || isSingleValue(getExpressionStats(node.getMax())))) {
+ if (!isSingleValue(node.getMax())) {
return visitExpression(node, context);
}
@@ -351,6 +351,12 @@ public class FilterStatsCalculator
return Optional.empty();
}
+ private boolean isSingleValue(Expression expression)
+ {
+ return (expression instanceof Literal)
+ || isSingleValue(getExpressionStats(expression));
+ }
+
private boolean isSingleValue(SymbolStatsEstimate stats)
{
return stats.getDistinctValuesCount() == 1.0
