Skip to content

perf(query): infer equality for identical singleton domains #20217

Description

@dantengsky

Summary

SimpleDomain::domain_eq() currently returns Full for any overlapping domains. As a result, two identical singleton domains such as [x, x] and [x, x] remain Full even though equality is guaranteed to be true. SimpleDomain::domain_noteq() has the symmetric missed inference and remains Full instead of all-false.

The current behavior is conservative and correct. This is a low-priority optimization opportunity, not a correctness bug.

Expected refinement

  • domain_eq([x, x], [x, x]) returns all-true.
  • domain_noteq([x, x], [x, x]) returns all-false.
  • Disjoint domains keep their existing exact results.
  • Overlapping non-singleton domains remain Full because domain ranges do not preserve row-level correlation.

Scope

  • Confirm the domain contract for singleton, empty, approximate, and unbounded domains before changing the generic comparison logic.
  • Add coverage for numeric, string, and nullable inputs.
  • Check the effect on constant folding, pruning, and selectivity estimation.

This was noticed while reviewing the LIKE domain work in #20207.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions