Skip to content

Commit

Permalink
Merge e3c35a9 into aad82fb
Browse files Browse the repository at this point in the history
  • Loading branch information
liukun4515 authored Sep 21, 2022
2 parents aad82fb + e3c35a9 commit ace7c67
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 5 deletions.
30 changes: 30 additions & 0 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,36 @@ impl Expr {
}
}

/// Return `IsTrue(Box(self))`
pub fn is_true(self) -> Expr {
Expr::IsTrue(Box::new(self))
}

/// Return `IsNotTrue(Box(self))`
pub fn is_not_true(self) -> Expr {
Expr::IsNotTrue(Box::new(self))
}

/// Return `IsFalse(Box(self))`
pub fn is_false(self) -> Expr {
Expr::IsFalse(Box::new(self))
}

/// Return `IsNotFalse(Box(self))`
pub fn is_not_false(self) -> Expr {
Expr::IsNotFalse(Box::new(self))
}

/// Return `IsUnknown(Box(self))`
pub fn is_unknown(self) -> Expr {
Expr::IsUnknown(Box::new(self))
}

/// Return `IsNotUnknown(Box(self))`
pub fn is_not_unknown(self) -> Expr {
Expr::IsNotUnknown(Box::new(self))
}

pub fn try_into_col(&self) -> Result<Column> {
match self {
Expr::Column(it) => Ok(it.clone()),
Expand Down
30 changes: 30 additions & 0 deletions datafusion/expr/src/expr_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,36 @@ pub fn is_null(expr: Expr) -> Expr {
Expr::IsNull(Box::new(expr))
}

/// Create is true expression
pub fn is_true(expr: Expr) -> Expr {
Expr::IsTrue(Box::new(expr))
}

/// Create is not true expression
pub fn is_not_true(expr: Expr) -> Expr {
Expr::IsNotTrue(Box::new(expr))
}

/// Create is false expression
pub fn is_false(expr: Expr) -> Expr {
Expr::IsFalse(Box::new(expr))
}

/// Create is not false expression
pub fn is_not_false(expr: Expr) -> Expr {
Expr::IsNotFalse(Box::new(expr))
}

/// Create is unknown expression
pub fn is_unknown(expr: Expr) -> Expr {
Expr::IsUnknown(Box::new(expr))
}

/// Create is not unknown expression
pub fn is_not_unknown(expr: Expr) -> Expr {
Expr::IsNotUnknown(Box::new(expr))
}

/// Create an convenience function representing a unary scalar function
macro_rules! unary_scalar_expr {
($ENUM:ident, $FUNC:ident, $DOC:expr) => {
Expand Down
Loading

0 comments on commit ace7c67

Please sign in to comment.