Amogh-2404 commented on code in PR #24668:
URL: https://github.com/apache/datafusion/pull/24668#discussion_r3859230386
##########
datafusion/physical-expr/src/expressions/negative.rs:
##########
@@ -128,7 +178,9 @@ impl PhysicalExpr for NegativeExpr {
interval: &Interval,
children: &[&Interval],
) -> Result<Option<Vec<Interval>>> {
- let negated_interval = interval.arithmetic_negate()?;
+ let Some(negated_interval) = negate_interval(interval)? else {
Review Comment:
Fixed in 1b7d5f96. `negate_interval` now falls back for signed
lower-unbounded intervals as well as arithmetic overflow. I added a unit test
for forward and inverse bounds, plus a Parquet statistics execution regression.
The reported query now retains `-128` and returns the correct row.
##########
datafusion/physical-expr/src/expressions/negative.rs:
##########
@@ -160,13 +212,31 @@ impl PhysicalExpr for NegativeExpr {
}
}
- /// The ordering of a [`NegativeExpr`] is simply the reverse of its child.
+ /// Negation reverses the child ordering unless signed integer values may
wrap.
fn get_properties(&self, children: &[ExprProperties]) ->
Result<ExprProperties> {
+ let (range, overflowed) = match negate_interval(&children[0].range)? {
+ Some(range) => (range, false),
+ None => (
+ Interval::make_unbounded(&children[0].range.data_type())?,
+ true,
+ ),
+ };
+ let may_wrap = children[0].range.data_type().is_signed_integer()
+ && (children[0].range.lower().is_null() || overflowed);
Review Comment:
Fixed in 1b7d5f96 by narrowing the scope. I restored
`NegativeExpr::get_properties` and the existing `order.slt` expectation instead
of changing shared cast metadata here. Two unbounded-source EXPLAIN cases now
cover both the widening cast and `-(-i)` without a global sort. I filed the
pre-existing single-negation ordering problem separately as #24683.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]