Skip to content

Commit

Permalink
Add missing uint8+uint8 and i8+i8 sum cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafasrepo committed Sep 28, 2022
1 parent c582e01 commit b1b27d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions datafusion/common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ macro_rules! typed_op {
};
}

macro_rules! impl_common_symmetic_cases_op {
macro_rules! impl_common_symmetric_cases_op {
($LHS:expr, $RHS:expr, $OPERATION:tt, [$([$L_TYPE:ident, $R_TYPE:ident, $O_TYPE:ident, $O_PRIM:ident]),+]) => {
match ($LHS, $RHS) {
$(
Expand Down Expand Up @@ -415,7 +415,13 @@ macro_rules! impl_common_cases_op {
(ScalarValue::Int16(lhs), ScalarValue::Int16(rhs)) => {
typed_op!(lhs, rhs, Int16, i16, $OPERATION)
}
_ => impl_common_symmetic_cases_op!(
(ScalarValue::UInt8(lhs), ScalarValue::UInt8(rhs)) => {
typed_op!(lhs, rhs, UInt8, u8, $OPERATION)
}
(ScalarValue::Int8(lhs), ScalarValue::Int8(rhs)) => {
typed_op!(lhs, rhs, Int8, i8, $OPERATION)
}
_ => impl_common_symmetric_cases_op!(
$LHS,
$RHS,
$OPERATION,
Expand Down
3 changes: 2 additions & 1 deletion datafusion/physical-expr/src/window/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ fn calculate_index_of_row<const BISECT_SIDE: bool, const SEARCH_SIDE: bool>(
};
let offset = ScalarValue::try_from_value(&value.get_datatype(), delta)?;
if SEARCH_SIDE == is_descending {
// TODO: ADD overflow check
// TODO: Handle positive overflows
value.add(&offset)
} else if value.is_unsigned() && value < &offset {
ScalarValue::try_from_value(&value.get_datatype(), 0)
} else {
// TODO: Handle negative overflows
value.sub(&offset)
}
})
Expand Down

0 comments on commit b1b27d2

Please sign in to comment.