Skip to content

Commit

Permalink
minor support mod operation for expr (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
liukun4515 authored Dec 20, 2021
1 parent 07b2985 commit b5082e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions ballista/rust/core/src/serde/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub(crate) fn from_proto_binary_op(op: &str) -> Result<Operator, BallistaError>
"Minus" => Ok(Operator::Minus),
"Multiply" => Ok(Operator::Multiply),
"Divide" => Ok(Operator::Divide),
"Modulo" => Ok(Operator::Modulo),
"Like" => Ok(Operator::Like),
"NotLike" => Ok(Operator::NotLike),
other => Err(proto_error(format!(
Expand Down
12 changes: 12 additions & 0 deletions datafusion/src/logical_plan/operators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ impl ops::Div for Expr {
}
}

impl ops::Rem for Expr {
type Output = Self;

fn rem(self, rhs: Self) -> Self {
binary_expr(self, Operator::Modulo, rhs)
}
}

#[cfg(test)]
mod tests {
use crate::prelude::lit;
Expand All @@ -149,5 +157,9 @@ mod tests {
format!("{:?}", lit(1u32) / lit(2u32)),
"UInt32(1) / UInt32(2)"
);
assert_eq!(
format!("{:?}", lit(1u32) % lit(2u32)),
"UInt32(1) % UInt32(2)"
);
}
}

0 comments on commit b5082e0

Please sign in to comment.