Skip to content

Commit b5082e0

Browse files
authored
minor support mod operation for expr (#1467)
1 parent 07b2985 commit b5082e0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ballista/rust/core/src/serde/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub(crate) fn from_proto_binary_op(op: &str) -> Result<Operator, BallistaError>
9797
"Minus" => Ok(Operator::Minus),
9898
"Multiply" => Ok(Operator::Multiply),
9999
"Divide" => Ok(Operator::Divide),
100+
"Modulo" => Ok(Operator::Modulo),
100101
"Like" => Ok(Operator::Like),
101102
"NotLike" => Ok(Operator::NotLike),
102103
other => Err(proto_error(format!(

datafusion/src/logical_plan/operators.rs

+12
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ impl ops::Div for Expr {
127127
}
128128
}
129129

130+
impl ops::Rem for Expr {
131+
type Output = Self;
132+
133+
fn rem(self, rhs: Self) -> Self {
134+
binary_expr(self, Operator::Modulo, rhs)
135+
}
136+
}
137+
130138
#[cfg(test)]
131139
mod tests {
132140
use crate::prelude::lit;
@@ -149,5 +157,9 @@ mod tests {
149157
format!("{:?}", lit(1u32) / lit(2u32)),
150158
"UInt32(1) / UInt32(2)"
151159
);
160+
assert_eq!(
161+
format!("{:?}", lit(1u32) % lit(2u32)),
162+
"UInt32(1) % UInt32(2)"
163+
);
152164
}
153165
}

0 commit comments

Comments
 (0)