diff --git a/datafusion/src/logical_plan/expr.rs b/datafusion/src/logical_plan/expr.rs index d808b6ba6b55..22de29b36971 100644 --- a/datafusion/src/logical_plan/expr.rs +++ b/datafusion/src/logical_plan/expr.rs @@ -941,6 +941,19 @@ impl Not for Expr { } } +impl std::fmt::Display for Expr { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Expr::BinaryExpr { + ref left, + ref right, + ref op, + } => write!(f, "{} {} {}", left, op, right), + _ => write!(f, "{:?}", self), + } + } +} + #[allow(clippy::boxed_local)] fn rewrite_boxed(boxed_expr: Box, rewriter: &mut R) -> Result> where @@ -1617,7 +1630,7 @@ impl fmt::Debug for Expr { Expr::IsNull(expr) => write!(f, "{:?} IS NULL", expr), Expr::IsNotNull(expr) => write!(f, "{:?} IS NOT NULL", expr), Expr::BinaryExpr { left, op, right } => { - write!(f, "{:?} {:?} {:?}", left, op, right) + write!(f, "{:?} {} {:?}", left, op, right) } Expr::Sort { expr, diff --git a/datafusion/src/logical_plan/operators.rs b/datafusion/src/logical_plan/operators.rs index 4e9ccb748463..0e00736faac8 100644 --- a/datafusion/src/logical_plan/operators.rs +++ b/datafusion/src/logical_plan/operators.rs @@ -129,19 +129,19 @@ mod tests { fn test_operators() { assert_eq!( format!("{:?}", lit(1u32) + lit(2u32)), - "UInt32(1) Plus UInt32(2)" + "UInt32(1) + UInt32(2)" ); assert_eq!( format!("{:?}", lit(1u32) - lit(2u32)), - "UInt32(1) Minus UInt32(2)" + "UInt32(1) - UInt32(2)" ); assert_eq!( format!("{:?}", lit(1u32) * lit(2u32)), - "UInt32(1) Multiply UInt32(2)" + "UInt32(1) * UInt32(2)" ); assert_eq!( format!("{:?}", lit(1u32) / lit(2u32)), - "UInt32(1) Divide UInt32(2)" + "UInt32(1) / UInt32(2)" ); } }