andygrove commented on a change in pull request #8865:
URL: https://github.com/apache/arrow/pull/8865#discussion_r539378327
##########
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:
nit: it would probably be more efficient to create the `>=` and `<=`
with the values reversed rather than wrapping in a `NOT` since this adds one
more operation and array creation. This is the sort of thing that could be
fixed in the opimizer phase too.
----------------------------------------------------------------
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]