EvaluationContext
and constraints for simplifications
#3387
+1,024
−413
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a direct precursor of enabling a
PredicateSimplification
rule in theREWRITING
phase of planning.This PR gives all planner rules including
Value
s andQueryPredicate
sValue
s andQueryPredicate
sthe ability to access the current evaluation context and to produce
QueryPlanConstraint
s as part of the result of the rule when yielding.Yielding has been extended to allow to yield
QueryPlanConstraint
s with the object that is being yielded.For conciseness and readability I added a fluent-like API for rules to use:
Note that for the propagation to work, we need to make sure that in each individual rule, objects (i.e. normally in a tree of
QueryPredicate
s orValue
s) that are not being preserved by the rule need to have their constraints preserved.Example:
COV(c58) IS NOT NULL AND FV(QOV(q, "x") = Literal(5)
can be simplified to if
c58
is bound to42
:TRUE AND FV(QOV(q, "x") = Literal(5)
with constraint thatCOV(c58) IS NOT NULL
which is assigned toTRUE
that can be further simplified to:
FV(QOV(q, "x") = Literal(5)
with constraint thatCOV(c58) IS NOT NULL
which now needs to be assigned to theValuePredicate
asTRUE
is gone. That means thatIdentityRule
must preserve the plan constraints that was previously assigned to theTruePredicate
.