You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2026/04/27 15:31:08 UTC
[PR] Update documentation for PhysicalExpr::evaluate_bounds [datafusion]
alamb opened a new pull request, #21879:
URL: https://github.com/apache/datafusion/pull/21879
## Which issue does this PR close?
- Related to https://github.com/apache/datafusion/pull/21651 from @Dandandan
## Rationale for this change
While reviewing https://github.com/apache/datafusion/pull/21651 I found that `sin(x)` is hard coded to always return `[-1, 1]` as its bounds regardless of its input:
https://github.com/apache/datafusion/blob/5901df58b21b8b4e36011744e7ddc17bcb6a37b3/datafusion/functions/src/math/bounds.rs#L27-L32
This is not clear from the docs and https://github.com/apache/datafusion/pull/21651 was assuming something different
## What changes are included in this PR?
1. Update the documentation to reflect the current state of the code (the bound are not exact)
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Update documentation for PhysicalExpr::evaluate_bounds [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #21879:
URL: https://github.com/apache/datafusion/pull/21879#discussion_r3156207483
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -181,10 +181,18 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
/// A `Result` containing the output interval for the expression in
/// case of success, or an error object in case of failure.
///
+ /// Note that the output bounds must form an **envelope** that contains all
+ /// possible outputs of the expression given the input bounds. While
+ /// expressions should output the tightest possible bounds, they do not need
+ /// to be exact and can be conservative.
+ ///
/// # Example
///
/// If the expression is `a + b`, and the input intervals are `a: [1, 2]`
/// and `b: [3, 4]`, then the output interval would be `[4, 6]`.
+ ///
+ /// If the expression is `sin(a)`, it is correct (though not precise) to
+ /// produce the interval `[-1, 1]` for any input interval for `a`.
Review Comment:
`Nan` perhaps?
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=87028bd40d413a14a296b77529201963
sqrt(-1.0): NaN
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -181,10 +181,18 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
/// A `Result` containing the output interval for the expression in
/// case of success, or an error object in case of failure.
///
+ /// Note that the output bounds must form an **envelope** that contains all
+ /// possible outputs of the expression given the input bounds. While
+ /// expressions should output the tightest possible bounds, they do not need
+ /// to be exact and can be conservative.
+ ///
/// # Example
///
/// If the expression is `a + b`, and the input intervals are `a: [1, 2]`
/// and `b: [3, 4]`, then the output interval would be `[4, 6]`.
+ ///
+ /// If the expression is `sin(a)`, it is correct (though not precise) to
+ /// produce the interval `[-1, 1]` for any input interval for `a`.
Review Comment:
[`Nan`, `Nan`] perhaps 🤔
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=87028bd40d413a14a296b77529201963
sqrt(-1.0): NaN
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Update documentation for PhysicalExpr::evaluate_bounds [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #21879:
URL: https://github.com/apache/datafusion/pull/21879
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Update documentation for PhysicalExpr::evaluate_bounds [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #21879:
URL: https://github.com/apache/datafusion/pull/21879#discussion_r3149823005
##########
datafusion/physical-expr-common/src/physical_expr.rs:
##########
@@ -181,10 +181,18 @@ pub trait PhysicalExpr: Any + Send + Sync + Display + Debug + DynEq + DynHash {
/// A `Result` containing the output interval for the expression in
/// case of success, or an error object in case of failure.
///
+ /// Note that the output bounds must form an **envelope** that contains all
+ /// possible outputs of the expression given the input bounds. While
+ /// expressions should output the tightest possible bounds, they do not need
+ /// to be exact and can be conservative.
+ ///
/// # Example
///
/// If the expression is `a + b`, and the input intervals are `a: [1, 2]`
/// and `b: [3, 4]`, then the output interval would be `[4, 6]`.
+ ///
+ /// If the expression is `sin(a)`, it is correct (though not precise) to
+ /// produce the interval `[-1, 1]` for any input interval for `a`.
Review Comment:
what would be the bounds for `sqrt(-1)`
🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Update documentation for PhysicalExpr::evaluate_bounds [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #21879:
URL: https://github.com/apache/datafusion/pull/21879#issuecomment-4337864112
Thanks @comphead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org