Class InferIsNotNull
java.lang.Object
org.elasticsearch.xpack.esql.rule.Rule<LogicalPlan,LogicalPlan>
org.elasticsearch.xpack.esql.optimizer.rules.logical.local.InferIsNotNull
Simplify IsNotNull targets by resolving the underlying expression to its root fields.
e.g.
(x + 1) / 2 IS NOT NULL --> x IS NOT NULL AND (x+1) / 2 IS NOT NULL
SUBSTRING(x, 3) > 4 IS NOT NULL --> x IS NOT NULL AND SUBSTRING(x, 3) > 4 IS NOT NULL
When dealing with multiple fields, a conjunction/disjunction based on the predicate:
(x + y) / 4 IS NOT NULL --> x IS NOT NULL AND y IS NOT NULL AND (x + y) / 4 IS NOT NULL
This handles the case of fields nested inside functions or expressions in order to avoid:
- having to evaluate the whole expression
- not pushing down the filter due to expression evaluation
IS NULL cannot be simplified since it leads to a disjunction which prevents the filter to be
pushed down:
(x + 1) IS NULL --> x IS NULL OR x + 1 IS NULL
and x IS NULL cannot be pushed down
Implementation-wise this rule goes bottom-up, keeping an alias up to date to the current plan and then looks for replacing the target.
Implementation-wise this rule goes bottom-up, keeping an alias up to date to the current plan and then looks for replacing the target.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(LogicalPlan plan) protected Set<Expression> resolveExpressionAsRootAttributes(Expression exp, AttributeMap<Expression> aliases) Unroll the expression to its references to get to the root fields that really matter for filtering.
-
Constructor Details
-
InferIsNotNull
public InferIsNotNull()
-
-
Method Details
-
apply
- Specified by:
applyin classRule<LogicalPlan,LogicalPlan>
-
resolveExpressionAsRootAttributes
protected Set<Expression> resolveExpressionAsRootAttributes(Expression exp, AttributeMap<Expression> aliases) Unroll the expression to its references to get to the root fields that really matter for filtering.
-