Skip to content

support OR operator in binary evaluate_bounds #15716

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

Merged
merged 3 commits into from
Apr 30, 2025

Conversation

davidhewitt
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Seems like this should have worked as per the commentary in the issue.

What changes are included in this PR?

  • add OR case to apply_operator
  • correct typo in error message
  • add some tests for evaluate_bounds

Are these changes tested?

Yes

Are there any user-facing changes?

Yes (public function now supports additional operator)

@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates labels Apr 15, 2025
@davidhewitt
Copy link
Contributor Author

The failing tests were added in #14189 and #14735, both which talk about supporting OR as a future possibility.

Ping @berkaysynnada as the reviewer / approver of both those PRs, does this PR look ok to you? If so I will update those tests so that CI is green here.

@berkaysynnada
Copy link
Contributor

Thank you @davidhewitt. I will review this today

Copy link
Contributor

@berkaysynnada berkaysynnada left a comment

Choose a reason for hiding this comment

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

LGTM. I really don't remember why didn't we add OR operator in apply_operator then :D

@berkaysynnada
Copy link
Contributor

Failing tests should be fixed after taking a merge from main

@davidhewitt
Copy link
Contributor Author

Thanks, I will probably get around to fixing this up on Tuesday 👍

@davidhewitt davidhewitt force-pushed the dh/evaluate-bounds-or branch from 161775e to f5092b6 Compare April 29, 2025 18:54
Copy link
Contributor Author

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Sorry for the delay @berkaysynnada. This should be good to review in full now.

Comment on lines +648 to +658
// Special case: true OR could in principle be propagated by 3 interval sets,
// (i.e. left true, or right true, or both true) however we do not support this yet.
if node_interval == &Interval::CERTAINLY_TRUE
&& self.graph[node]
.expr
.as_any()
.downcast_ref::<BinaryExpr>()
.is_some_and(|expr| expr.op() == &Operator::Or)
{
return not_impl_err!("OR operator cannot yet propagate true intervals");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to add this to keep the invalid-analysis tests failing. I could move this inside the implementation of PhysicalExpr for BinaryExpr, however that case currently returns Ok(Some(vec![])) and it wasn't clear to me if it was ok to change that case to be failing.

Copy link
Contributor

Choose a reason for hiding this comment

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

this makes sense to me

Copy link
Contributor

@berkaysynnada berkaysynnada May 2, 2025

Choose a reason for hiding this comment

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

Rather than error, this case should go to PropagationResult::CannotPropagate, if any child is true, or PropagationResult::Infeasible if both of them are false

@alamb alamb merged commit 7b370e2 into apache:main Apr 30, 2025
27 checks passed
@alamb
Copy link
Contributor

alamb commented Apr 30, 2025

Thanks @davidhewitt and @berkaysynnada

@davidhewitt
Copy link
Contributor Author

Thanks!

nirnayroy pushed a commit to nirnayroy/datafusion that referenced this pull request May 2, 2025
* support OR operator in binary `evaluate_bounds`

* fixup tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interval arithmetic apply_operator does not support OR
3 participants