avantgardnerio commented on code in PR #5387:
URL: https://github.com/apache/arrow-datafusion/pull/5387#discussion_r1117247428
##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -4249,4 +4276,67 @@ mod tests {
Ok(())
}
+
+ #[test]
+ fn test_display_and_or_combo() {
+ let expr = BinaryExpr::new(
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(1)),
+ Operator::And,
+ lit(ScalarValue::from(2)),
+ )),
+ Operator::And,
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(3)),
+ Operator::And,
+ lit(ScalarValue::from(4)),
+ )),
+ );
+ assert_eq!(expr.to_string(), "1 AND 2 AND 3 AND 4");
+
+ let expr = BinaryExpr::new(
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(1)),
+ Operator::Or,
+ lit(ScalarValue::from(2)),
+ )),
+ Operator::Or,
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(3)),
+ Operator::Or,
+ lit(ScalarValue::from(4)),
+ )),
+ );
+ assert_eq!(expr.to_string(), "1 OR 2 OR 3 OR 4");
+
+ let expr = BinaryExpr::new(
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(1)),
+ Operator::And,
+ lit(ScalarValue::from(2)),
+ )),
+ Operator::Or,
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(3)),
+ Operator::And,
+ lit(ScalarValue::from(4)),
+ )),
+ );
+ assert_eq!(expr.to_string(), "1 AND 2 OR 3 AND 4");
+
+ let expr = BinaryExpr::new(
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(1)),
+ Operator::Or,
+ lit(ScalarValue::from(2)),
+ )),
+ Operator::And,
+ Arc::new(BinaryExpr::new(
+ lit(ScalarValue::from(3)),
+ Operator::Or,
+ lit(ScalarValue::from(4)),
+ )),
+ );
+ assert_eq!(expr.to_string(), "(1 OR 2) AND (3 OR 4)");
Review Comment:
> The new format looks pretty star_struck
Agreed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]