You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/08/23 10:59:38 UTC
[arrow-datafusion] branch master updated: impl not for expr (#763)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new c636d35 impl not for expr (#763)
c636d35 is described below
commit c636d35fdba46a49224ab0c74ec8eda2ad2d92ab
Author: Jiayu Liu <Ji...@users.noreply.github.com>
AuthorDate: Mon Aug 23 18:59:34 2021 +0800
impl not for expr (#763)
---
datafusion/src/logical_plan/expr.rs | 16 +++++++++++++++-
datafusion/src/physical_optimizer/pruning.rs | 2 +-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/datafusion/src/logical_plan/expr.rs b/datafusion/src/logical_plan/expr.rs
index e495284..8978b83 100644
--- a/datafusion/src/logical_plan/expr.rs
+++ b/datafusion/src/logical_plan/expr.rs
@@ -32,6 +32,7 @@ use functions::{ReturnTypeFunction, ScalarFunctionImplementation, Signature};
use std::collections::{HashMap, HashSet};
use std::convert::Infallible;
use std::fmt;
+use std::ops::Not;
use std::str::FromStr;
use std::sync::Arc;
@@ -580,7 +581,7 @@ impl Expr {
/// Return `!self`
#[allow(clippy::should_implement_trait)]
pub fn not(self) -> Expr {
- Expr::Not(Box::new(self))
+ !self
}
/// Calculate the modulus of two expressions.
@@ -925,6 +926,14 @@ impl Expr {
}
}
+impl Not for Expr {
+ type Output = Self;
+
+ fn not(self) -> Self::Output {
+ Expr::Not(Box::new(self))
+ }
+}
+
#[allow(clippy::boxed_local)]
fn rewrite_boxed<R>(boxed_expr: Box<Expr>, rewriter: &mut R) -> Result<Box<Expr>>
where
@@ -1994,6 +2003,11 @@ mod tests {
DFField::new(Some(relation), column, DataType::Int8, false)
}
+ #[test]
+ fn test_not() {
+ assert_eq!(lit(1).not(), !lit(1));
+ }
+
macro_rules! test_unary_scalar_expr {
($ENUM:ident, $FUNC:ident) => {{
if let Expr::ScalarFunction { fun, args } = $FUNC(col("tableA.a")) {
diff --git a/datafusion/src/physical_optimizer/pruning.rs b/datafusion/src/physical_optimizer/pruning.rs
index c6f7647..2a10cfa 100644
--- a/datafusion/src/physical_optimizer/pruning.rs
+++ b/datafusion/src/physical_optimizer/pruning.rs
@@ -571,7 +571,7 @@ fn build_single_column_expr(
if is_not {
// The only way we know a column couldn't match is if both the min and max are true
// !(min && max)
- Some((min.and(max)).not())
+ Some(!(min.and(max)))
} else {
// the only way we know a column couldn't match is if both the min and max are false
// !(!min && !max) --> min || max