[−][src]Enum datafusion::logical_plan::Expr
Expr
is a logical expression. A logical expression is something like 1 + 1
, or CAST(c1 AS int)
.
Logical expressions know how to compute its arrow::datatypes::DataType and nullability.
Expr
is a central struct of DataFusion's query API.
Examples
let expr = Expr::Column("c1".to_string()) + Expr::Column("c2".to_string()); println!("{:?}", expr);
Variants
An expression with a specific name.
Column(String)
A named reference to a field in a schema.
A named reference to a variable in a registry.
Literal(ScalarValue)
A constant value.
A binary expression such as "age > 21"
Fields of BinaryExpr
Negation of an expression. The expression's type must be a boolean to make sense.
Whether an expression is not Null. This expression is never null.
Whether an expression is Null. This expression is never null.
arithmetic negation of an expression, the operand must be of a signed numeric data type
Whether an expression is between a given range.
Fields of Between
The CASE expression is similar to a series of nested if/else and there are two forms that can be used. The first form consists of a series of boolean "when" expressions with corresponding "then" expressions, and an optional "else" expression.
CASE WHEN condition THEN result [WHEN ...] [ELSE result] END
The second form uses a base expression and then a series of "when" clauses that match on a literal value.
CASE expression WHEN value THEN result [WHEN ...] [ELSE result] END
Fields of Case
Casts the expression to a given type. This expression is guaranteed to have a fixed type.
Fields of Cast
A sort expression, that can be used to sort values.
Fields of Sort
Represents the call of a built-in scalar function with a set of arguments.
Fields of ScalarFunction
fun: BuiltinScalarFunction
The function
args: Vec<Expr>
List of expressions to feed to the functions as arguments
Represents the call of a user-defined scalar function with arguments.
Fields of ScalarUDF
Represents the call of an aggregate built-in function with arguments.
Fields of AggregateFunction
fun: AggregateFunction
Name of the function
args: Vec<Expr>
List of expressions to feed to the functions as arguments
distinct: bool
Whether this is a DISTINCT aggregation or not
aggregate function
Fields of AggregateUDF
fun: Arc<AggregateUDF>
The function
args: Vec<Expr>
List of expressions to feed to the functions as arguments
Returns whether the list contains the expr value.
Fields of InList
Represents a reference to all fields in a schema.
Implementations
impl Expr
[src]
pub fn get_type(&self, schema: &DFSchema) -> Result<DataType>
[src]
Returns the arrow::datatypes::DataType of the expression based on arrow::datatypes::Schema.
Errors
This function errors when it is not possible to compute its arrow::datatypes::DataType.
This happens when e.g. the expression refers to a column that does not exist in the schema, or when
the expression is incorrectly typed (e.g. [utf8] + [bool]
).
pub fn nullable(&self, input_schema: &DFSchema) -> Result<bool>
[src]
Returns the nullability of the expression based on arrow::datatypes::Schema.
Errors
This function errors when it is not possible to compute its nullability. This happens when the expression refers to a column that does not exist in the schema.
pub fn name(&self, input_schema: &DFSchema) -> Result<String>
[src]
Returns the name of this expression based on arrow::datatypes::Schema.
This represents how a column with this expression is named when no alias is chosen
pub fn to_field(&self, input_schema: &DFSchema) -> Result<DFField>
[src]
Returns a arrow::datatypes::Field compatible with this expression.
pub fn cast_to(
&self,
cast_to_type: &DataType,
schema: &DFSchema
) -> Result<Expr>
[src]
&self,
cast_to_type: &DataType,
schema: &DFSchema
) -> Result<Expr>
Wraps this expression in a cast to a target arrow::datatypes::DataType.
Errors
This function errors when it is impossible to cast the expression to the target arrow::datatypes::DataType.
pub fn eq(&self, other: Expr) -> Expr
[src]
Equal
pub fn not_eq(&self, other: Expr) -> Expr
[src]
Not equal
pub fn gt(&self, other: Expr) -> Expr
[src]
Greater than
pub fn gt_eq(&self, other: Expr) -> Expr
[src]
Greater than or equal to
pub fn lt(&self, other: Expr) -> Expr
[src]
Less than
pub fn lt_eq(&self, other: Expr) -> Expr
[src]
Less than or equal to
pub fn and(&self, other: Expr) -> Expr
[src]
And
pub fn or(&self, other: Expr) -> Expr
[src]
Or
pub fn not(&self) -> Expr
[src]
Not
pub fn modulus(&self, other: Expr) -> Expr
[src]
Calculate the modulus of two expressions
pub fn like(&self, other: Expr) -> Expr
[src]
like (string) another expression
pub fn not_like(&self, other: Expr) -> Expr
[src]
not like another expression
pub fn alias(&self, name: &str) -> Expr
[src]
Alias
pub fn in_list(&self, list: Vec<Expr>, negated: bool) -> Expr
[src]
InList
pub fn sort(&self, asc: bool, nulls_first: bool) -> Expr
[src]
Create a sort expression from an existing expression.
let sort_expr = col("foo").sort(true, true); // SORT ASC NULLS_FIRST
Trait Implementations
impl Add<Expr> for Expr
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
impl Clone for Expr
[src]
impl Debug for Expr
[src]
impl Div<Expr> for Expr
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self
[src]
impl Mul<Expr> for Expr
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self
[src]
impl PartialEq<Expr> for Expr
[src]
impl StructuralPartialEq for Expr
[src]
impl Sub<Expr> for Expr
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Expr
[src]
impl Send for Expr
[src]
impl Sync for Expr
[src]
impl Unpin for Expr
[src]
impl !UnwindSafe for Expr
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,