Skip to content

Conversation

@pepijnve
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

The discussion in #18625 made it clear that the naming of the truth value intervals would benefit from consistency. After some back and forth we concluded that consistency with the SQL specification seemed like the best idea.
This PR renames the boolean Interval and NullableInterval constants to all be consistent.

What changes are included in this PR?

Mechanical refactoring where the following renames were performed:

  • Interval::CERTAINLY_TRUE -> Interval::TRUE
  • Interval::CERTAINLY_FALSE -> Interval::FALSE
  • Interval::UNCERTAIN -> Interval::TRUE_OR_FALSE
  • NullableInterval::UNCERTAIN -> NullableInterval::ANY_TRUTH_VALUE

The old constant names have been retained with a deprecation note.

Are these changes tested?

No new code

Are there any user-facing changes?

Yes, the old constants are now marked deprecated

CERTAINLY_FALSE -> FALSE
CERTAINLY_TRUE -> TRUE
UNCERTAIN -> TRUE_OR_FALSE
@pepijnve pepijnve marked this pull request as ready for review November 12, 2025 16:08
@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates functions Changes to functions implementation physical-plan Changes to the physical-plan crate labels Nov 12, 2025
}

// Tests that there's no such thing as a 'null' boolean interval.
// An interval with two `Boolean(None)` boundaries is normalised to `Interval::UNCERTAIN`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// An interval with two `Boolean(None)` boundaries is normalised to `Interval::TRUE_OR_FALSE`.

@pepijnve
Copy link
Contributor Author

Thanks @martin-g. I hadn't realised the rename refactoring did not update the comments as well.

@martin-g
Copy link
Member

I noticed one and then let ripgrep catch them all 😄

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pepijnve - I think this is a really nice improvement to the code


if self.op.eq(&Operator::And) {
if interval.eq(&Interval::CERTAINLY_TRUE) {
if interval.eq(&Interval::TRUE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these changes really make the code easier to read and understand -- thank you @pepijnve

/// This interval is semantically equivalent to [Interval::FALSE].
pub const FALSE: Self = NullableInterval::NotNull {
values: Interval::CERTAINLY_FALSE,
values: Interval::FALSE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this now has a very nice symmetry to it

# Conflicts:
#	datafusion/expr-common/src/interval_arithmetic.rs
@pepijnve
Copy link
Contributor Author

Merge conflicts resolved. All other comments have been addressed.

@alamb
Copy link
Contributor

alamb commented Nov 17, 2025

I will merge this once CI passes

@alamb alamb added this pull request to the merge queue Nov 17, 2025
@alamb
Copy link
Contributor

alamb commented Nov 17, 2025

Thank you @pepijnve

Merged via the queue into apache:main with commit bd30fe2 Nov 17, 2025
32 checks passed
@pepijnve pepijnve deleted the interval_constants branch November 18, 2025 12:02
logan-keede pushed a commit to logan-keede/datafusion that referenced this pull request Nov 23, 2025
…he#18654)

## Which issue does this PR close?

- None, followup to apache#18625

## Rationale for this change

The discussion in apache#18625 made it clear that the naming of the truth
value intervals would benefit from consistency. After some back and
forth we concluded that consistency with the SQL specification seemed
like the best idea.
This PR renames the boolean `Interval` and `NullableInterval` constants
to all be consistent.

## What changes are included in this PR?

Mechanical refactoring where the following renames were performed:
- `Interval::CERTAINLY_TRUE` -> `Interval::TRUE`
- `Interval::CERTAINLY_FALSE` -> `Interval::FALSE`
- `Interval::UNCERTAIN` -> `Interval::TRUE_OR_FALSE`
- `NullableInterval::UNCERTAIN` -> `NullableInterval::ANY_TRUTH_VALUE`

The old constant names have been retained with a deprecation note.

## Are these changes tested?

No new code

## Are there any user-facing changes?

Yes, the old constants are now marked deprecated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants