Skip to content

Simplification rules should emit constraints #3424

@hatyo

Description

@hatyo

The current implementation of constant folding rules for QueryPredicates (such as those introduced in #3404, #3418, and #3417) has a limitation: these rules don't contribute constraints that are essential for the plan cache key used in generating the physical plan. As a workaround, the plan generator currently compensates by adding extra constraints related to boolean, null, and non-null literals (see #3413).

This issue proposes refactoring the code to improve this situation. We should modify the constant folding rules themselves to emit the necessary constraints directly, and then remove the compensating logic from the plan generator.

This approach offers several benefits. First, it will significantly improve code maintainability by centralizing constraint generation within the constant folding rules, making constraint production more localized and predictable. Second, by ensuring constraints are correctly handled during constant folding, we can safely introduce more aggressive constant folding rules without risking incorrect plan caching. Finally, removing the redundant constraint handling from the plan generator will simplify the overall codebase.

This change will primarily affect the code related to QueryPredicate constant folding and the plan generator.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestplannerRelated to the query planner

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions