Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions datafusion/proto/src/from_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,17 @@ fn from_proto_binary_op(op: &str) -> Result<Operator, Error> {
"Modulo" => Ok(Operator::Modulo),
"Like" => Ok(Operator::Like),
"NotLike" => Ok(Operator::NotLike),
"IsDistinctFrom" => Ok(Operator::IsDistinctFrom),
"IsNotDistinctFrom" => Ok(Operator::IsNotDistinctFrom),
"BitwiseAnd" => Ok(Operator::BitwiseAnd),
"BitwiseOr" => Ok(Operator::BitwiseOr),
"BitwiseShiftLeft" => Ok(Operator::BitwiseShiftLeft),
"BitwiseShiftRight" => Ok(Operator::BitwiseShiftRight),
"RegexIMatch" => Ok(Operator::RegexIMatch),
"RegexMatch" => Ok(Operator::RegexMatch),
"RegexNotIMatch" => Ok(Operator::RegexNotIMatch),
"RegexNotMatch" => Ok(Operator::RegexNotMatch),
"StringConcat" => Ok(Operator::StringConcat),
other => Err(proto_error(format!(
"Unsupported binary operator '{:?}'",
other
Expand Down
36 changes: 35 additions & 1 deletion datafusion/proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod roundtrip_tests {
use datafusion_expr::logical_plan::{Extension, UserDefinedLogicalNode};
use datafusion_expr::{
col, lit, Accumulator, AggregateFunction, AggregateState,
BuiltinScalarFunction::Sqrt, Expr, LogicalPlan, Volatility,
BuiltinScalarFunction::Sqrt, Expr, LogicalPlan, Operator, Volatility,
};
use prost::Message;
use std::any::Any;
Expand Down Expand Up @@ -836,6 +836,40 @@ mod roundtrip_tests {
roundtrip_expr_test(test_expr, ctx);
}

#[test]
fn roundtrip_binary_op() {
fn test(op: Operator) {
let test_expr = Expr::BinaryExpr {
left: Box::new(lit(1.0_f32)),
op,
right: Box::new(lit(2.0_f32)),
};
let ctx = SessionContext::new();
roundtrip_expr_test(test_expr, ctx);
}
test(Operator::StringConcat);
test(Operator::RegexNotIMatch);
test(Operator::RegexNotMatch);
test(Operator::RegexIMatch);
test(Operator::RegexMatch);
test(Operator::Like);
test(Operator::NotLike);
test(Operator::BitwiseShiftRight);
test(Operator::BitwiseShiftLeft);
test(Operator::BitwiseAnd);
test(Operator::BitwiseOr);
test(Operator::IsDistinctFrom);
test(Operator::IsNotDistinctFrom);
test(Operator::And);
test(Operator::Or);
test(Operator::Eq);
test(Operator::NotEq);
test(Operator::Lt);
test(Operator::LtEq);
test(Operator::Gt);
test(Operator::GtEq);
}

#[test]
fn roundtrip_case() {
let test_expr = Expr::Case {
Expand Down