andygrove commented on a change in pull request #8865:
URL: https://github.com/apache/arrow/pull/8865#discussion_r539602557



##########
File path: rust/datafusion/src/optimizer/utils.rs
##########
@@ -370,6 +385,27 @@ pub fn rewrite_expression(expr: &Expr, expressions: 
&Vec<Expr>) -> Result<Expr>
             asc: asc.clone(),
             nulls_first: nulls_first.clone(),
         }),
+        Expr::Between { negated, .. } => {
+            let expr = Expr::BinaryExpr {
+                left: Box::new(Expr::BinaryExpr {
+                    left: Box::new(expressions[0].clone()),
+                    op: Operator::GtEq,
+                    right: Box::new(expressions[1].clone()),
+                }),
+                op: Operator::And,
+                right: Box::new(Expr::BinaryExpr {
+                    left: Box::new(expressions[0].clone()),
+                    op: Operator::LtEq,
+                    right: Box::new(expressions[2].clone()),
+                }),
+            };
+
+            if *negated {
+                Ok(Expr::Not(Box::new(expr)))

Review comment:
       On second thoughts, we should leave the logical plan as it is so we 
don't lose the semantics. We can optimize this in the physical plan in the 
future.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to