Skip to content

EvaluationContext and constraints for simplifications #3387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

normen662
Copy link
Contributor

@normen662 normen662 commented Jun 10, 2025

This PR is a direct precursor of enabling a PredicateSimplification rule in the REWRITING phase of planning.

This PR gives all planner rules including

  • cascades planner rules
  • simplification rules for Values and QueryPredicates
  • computation rules for Values and QueryPredicates

the ability to access the current evaluation context and to produce QueryPlanConstraints as part of the result of the rule when yielding.

Yielding has been extended to allow to yield QueryPlanConstraints with the object that is being yielded.

For conciseness and readability I added a fluent-like API for rules to use:

call.yieldResultBuilder()
    .addConstraintsFrom(bindings.get(getMatcher()))
    .addConstraintsFrom(Sets.difference(allMajorOfMinors, retainedMajorOfMinors))
    .yieldResult(simplifiedPredicate);

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 QueryPredicates or Values) 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 to 42:

TRUE AND FV(QOV(q, "x") = Literal(5) with constraint that COV(c58) IS NOT NULL which is assigned to TRUE

that can be further simplified to:

FV(QOV(q, "x") = Literal(5) with constraint that COV(c58) IS NOT NULL which now needs to be assigned to the ValuePredicate as TRUE is gone. That means that IdentityRule must preserve the plan constraints that was previously assigned to the TruePredicate.

@normen662 normen662 requested a review from hatyo June 10, 2025 07:39
@normen662 normen662 added the enhancement New feature or request label Jun 10, 2025
@normen662 normen662 force-pushed the ec-and-constraints-for-simplifications branch from d910c99 to 77af6bc Compare June 10, 2025 07:51
@normen662 normen662 force-pushed the ec-and-constraints-for-simplifications branch from 77af6bc to 3543a97 Compare June 10, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant