theirix commented on code in PR #16831:
URL: https://github.com/apache/datafusion/pull/16831#discussion_r2223625696
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -1790,6 +1808,27 @@ impl ScalarValue {
(Self::Float64(Some(l)), Self::Float64(Some(r))) => {
Some((l - r).abs().round() as _)
}
+ (
+ Self::Decimal128(Some(l), lprecision, lscale),
+ Self::Decimal128(Some(r), rprecision, rscale),
+ ) => {
+ if lprecision == rprecision && lscale == rscale {
+ l.checked_sub(*r)?.abs().to_usize()
+ } else {
+ None
+ }
+ }
+ (
+ Self::Decimal256(Some(l), lprecision, lscale),
+ Self::Decimal256(Some(r), rprecision, rscale),
+ ) => {
+ if lprecision == rprecision && lscale == rscale {
+ // l.checked_sub(*r).and_then( |v| v.checked_abs()
).and_then(|v| v.to_usize() )
+ l.checked_sub(*r)?.checked_abs()?.to_usize()
Review Comment:
I think it does – `distance` returns an `Option`, and this code returns None
on each failing combinator. Is it correct? Added tests to be sure.
--
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]