Skip to content

Introduce QueryConstraints to LogicalPlan #4222

Closed

Description

@mingmwang

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

I would like to introduce below structs to LogicalPlan and implement the QueryConstraints propagation logic.
Couple of logical optimization Rules(FilterPushDown, ReduceOuterJoin, FilterNullJoinKeys, EliminateFilter, ReduceCrossJoin...) can benefit from it and will simply the logic to deal with predicate/expr processing and will be able to cover more cases.

struct QueryConstraints {
    eq_props: EquivalenceProperties,
    null_props: NullProperties,
    not_null_props: NotNullProperties,
    other_constraints: Vec<Expr>,
    schema: SchemaRef
}
pub struct EquivalenceProperties {
    eq_classes: Vec<EquivalentClass>,
}
pub struct NullProperties {
    null_columns: Vec<Column>,
}
pub struct NotNullProperties {
    not_null_columns: Vec<Column>,
}

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Activity

  1. alamb commented on Nov 17, 2022

    @alamb
    Contributor

    Maybe this could be unified somehow with the analysis framework that @isidentical is working on

  2. isidentical commented on Nov 18, 2022

    @isidentical
    Contributor

    Exactly! The only major distinction I see is that, these seems to be constraints only for stuff that can be inferred at the logical planning time (so no stats, only schema + the existing query) which in turn might restrict some use cases but also might be much more reliable source. I am still in the middle on how we can unify these though 🤔

  3. alamb commented on Jan 13, 2026

    @alamb
    Contributor

    DataFusion now has https://docs.rs/datafusion/latest/datafusion/common/struct.Constraints.html which is what I think this PR proposes. Closing down

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions