You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "avantgardnerio (via GitHub)" <gi...@apache.org> on 2023/02/24 16:10:42 UTC

[GitHub] [arrow-datafusion] avantgardnerio commented on a diff in pull request #5387: fix: misc phys. expression display bugs

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org