Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
Expr in datafusion::logical_expr - Rust
[go: Go Back, main page]

datafusion::logical_expr

Enum Expr

Source
pub enum Expr {
Show 33 variants Alias(Alias), Column(Column), ScalarVariable(DataType, Vec<String>), Literal(ScalarValue), BinaryExpr(BinaryExpr), Like(Like), SimilarTo(Like), Not(Box<Expr>), IsNotNull(Box<Expr>), IsNull(Box<Expr>), IsTrue(Box<Expr>), IsFalse(Box<Expr>), IsUnknown(Box<Expr>), IsNotTrue(Box<Expr>), IsNotFalse(Box<Expr>), IsNotUnknown(Box<Expr>), Negative(Box<Expr>), Between(Between), Case(Case), Cast(Cast), TryCast(TryCast), ScalarFunction(ScalarFunction), AggregateFunction(AggregateFunction), WindowFunction(WindowFunction), InList(InList), Exists(Exists), InSubquery(InSubquery), ScalarSubquery(Subquery), Wildcard { qualifier: Option<TableReference>, options: WildcardOptions, }, GroupingSet(GroupingSet), Placeholder(Placeholder), OuterReferenceColumn(DataType, Column), Unnest(Unnest),
}
Expand description

Represents logical expressions such as A + 1, or CAST(c1 AS int).

For example the expression A + 1 will be represented as

  BinaryExpr {
    left: Expr::Column("A"),
    op: Operator::Plus,
    right: Expr::Literal(ScalarValue::Int32(Some(1)))
 }

ยงCreating Expressions

Exprs can be created directly, but it is often easier and less verbose to use the fluent APIs in crate::expr_fn such as col and lit, or methods such as Expr::alias, Expr::cast_to, and Expr::Like).

See also ExprFunctionExt for creating aggregate and window functions.

ยงSchema Access

See ExprSchemable::get_type to access the DataType and nullability of an Expr.

ยงVisiting and Rewriting Exprs

The Expr struct implements the TreeNode trait for walking and rewriting expressions. For example TreeNode::apply recursively visits an Expr and TreeNode::transform can be used to rewrite an expression. See the examples below and TreeNode for more information.

ยงExamples

ยงColumn references and literals

Expr::Column refer to the values of columns and are often created with the col function. For example to create an expression c1 referring to column named โ€œc1โ€:

let expr = col("c1");
assert_eq!(expr, Expr::Column(Column::from_name("c1")));

Expr::Literal refer to literal, or constant, values. These are created with the lit function. For example to create an expression 42:

// All literals are strongly typed in DataFusion. To make an `i64` 42:
let expr = lit(42i64);
assert_eq!(expr, Expr::Literal(ScalarValue::Int64(Some(42))));
// To make a (typed) NULL:
let expr = Expr::Literal(ScalarValue::Int64(None));
// to make an (untyped) NULL (the optimizer will coerce this to the correct type):
let expr = lit(ScalarValue::Null);

ยงBinary Expressions

Exprs implement traits that allow easy to understand construction of more complex expressions. For example, to create c1 + c2 to add columns โ€œc1โ€ and โ€œc2โ€ together

// Use the `+` operator to add two columns together
let expr = col("c1") + col("c2");
assert!(matches!(expr, Expr::BinaryExpr { ..} ));
if let Expr::BinaryExpr(binary_expr) = expr {
  assert_eq!(*binary_expr.left, col("c1"));
  assert_eq!(*binary_expr.right, col("c2"));
  assert_eq!(binary_expr.op, Operator::Plus);
}

The expression c1 = 42 to compares the value in column โ€œc1โ€ to the literal value 42:

let expr = col("c1").eq(lit(42_i32));
assert!(matches!(expr, Expr::BinaryExpr { .. } ));
if let Expr::BinaryExpr(binary_expr) = expr {
  assert_eq!(*binary_expr.left, col("c1"));
  let scalar = ScalarValue::Int32(Some(42));
  assert_eq!(*binary_expr.right, Expr::Literal(scalar));
  assert_eq!(binary_expr.op, Operator::Eq);
}

Here is how to implement the equivalent of SELECT * to select all Expr::Column from a DFSchemaโ€™s columns:

// Create a schema c1(int, c2 float)
let arrow_schema = Schema::new(vec![
   Field::new("c1", DataType::Int32, false),
   Field::new("c2", DataType::Float64, false),
]);
// DFSchema is a an Arrow schema with optional relation name
let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema)
  .unwrap();

// Form Vec<Expr> with an expression for each column in the schema
let exprs: Vec<_> = df_schema.iter()
  .map(Expr::from)
  .collect();

assert_eq!(exprs, vec![
  Expr::from(Column::from_qualified_name("t1.c1")),
  Expr::from(Column::from_qualified_name("t1.c2")),
]);

ยงVisiting and Rewriting Exprs

Here is an example that finds all literals in an Expr tree:

use datafusion_common::ScalarValue;
use datafusion_common::tree_node::{TreeNode, TreeNodeRecursion};
// Expression a = 5 AND b = 6
let expr = col("a").eq(lit(5)) & col("b").eq(lit(6));
// find all literals in a HashMap
let mut scalars = HashSet::new();
// apply recursively visits all nodes in the expression tree
expr.apply(|e| {
   if let Expr::Literal(scalar) = e {
      scalars.insert(scalar);
   }
   // The return value controls whether to continue visiting the tree
   Ok(TreeNodeRecursion::Continue)
}).unwrap();;
// All subtrees have been visited and literals found
assert_eq!(scalars.len(), 2);
assert!(scalars.contains(&ScalarValue::Int32(Some(5))));
assert!(scalars.contains(&ScalarValue::Int32(Some(6))));

Rewrite an expression, replacing references to column โ€œaโ€ in an to the literal 42:

// expression a = 5 AND b = 6
let expr = col("a").eq(lit(5)).and(col("b").eq(lit(6)));
// rewrite all references to column "a" to the literal 42
let rewritten = expr.transform(|e| {
 if let Expr::Column(c) = &e {
   if &c.name == "a" {
     // return Transformed::yes to indicate the node was changed
     return Ok(Transformed::yes(lit(42)))
   }
 }
 // return Transformed::no to indicate the node was not changed
 Ok(Transformed::no(e))
}).unwrap();
// The expression has been rewritten
assert!(rewritten.transformed);
// to 42 = 5 AND b = 6
assert_eq!(rewritten.data, lit(42).eq(lit(5)).and(col("b").eq(lit(6))));

Variantsยง

ยง

Alias(Alias)

An expression with a specific name.

ยง

Column(Column)

A named reference to a qualified field in a schema.

ยง

ScalarVariable(DataType, Vec<String>)

A named reference to a variable in a registry.

ยง

Literal(ScalarValue)

A constant value.

ยง

BinaryExpr(BinaryExpr)

A binary expression such as โ€œage > 21โ€

ยง

Like(Like)

LIKE expression

ยง

SimilarTo(Like)

LIKE expression that uses regular expressions

ยง

Not(Box<Expr>)

Negation of an expression. The expressionโ€™s type must be a boolean to make sense.

ยง

IsNotNull(Box<Expr>)

True if argument is not NULL, false otherwise. This expression itself is never NULL.

ยง

IsNull(Box<Expr>)

True if argument is NULL, false otherwise. This expression itself is never NULL.

ยง

IsTrue(Box<Expr>)

True if argument is true, false otherwise. This expression itself is never NULL.

ยง

IsFalse(Box<Expr>)

True if argument is false, false otherwise. This expression itself is never NULL.

ยง

IsUnknown(Box<Expr>)

True if argument is NULL, false otherwise. This expression itself is never NULL.

ยง

IsNotTrue(Box<Expr>)

True if argument is FALSE or NULL, false otherwise. This expression itself is never NULL.

ยง

IsNotFalse(Box<Expr>)

True if argument is TRUE OR NULL, false otherwise. This expression itself is never NULL.

ยง

IsNotUnknown(Box<Expr>)

True if argument is TRUE or FALSE, false otherwise. This expression itself is never NULL.

ยง

Negative(Box<Expr>)

arithmetic negation of an expression, the operand must be of a signed numeric data type

ยง

Between(Between)

Whether an expression is between a given range.

ยง

Case(Case)

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
ยง

Cast(Cast)

Casts the expression to a given type and will return a runtime error if the expression cannot be cast. This expression is guaranteed to have a fixed type.

ยง

TryCast(TryCast)

Casts the expression to a given type and will return a null value if the expression cannot be cast. This expression is guaranteed to have a fixed type.

ยง

ScalarFunction(ScalarFunction)

Represents the call of a scalar function with a set of arguments.

ยง

AggregateFunction(AggregateFunction)

Calls an aggregate function with arguments, and optional ORDER BY, FILTER, DISTINCT and NULL TREATMENT.

See also ExprFunctionExt to set these fields.

ยง

WindowFunction(WindowFunction)

Represents the call of a window function with arguments.

ยง

InList(InList)

Returns whether the list contains the expr value.

ยง

Exists(Exists)

EXISTS subquery

ยง

InSubquery(InSubquery)

IN subquery

ยง

ScalarSubquery(Subquery)

Scalar subquery

ยง

Wildcard

Represents a reference to all available fields in a specific schema, with an optional (schema) qualifier.

This expr has to be resolved to a list of columns before translating logical plan into physical plan.

ยง

GroupingSet(GroupingSet)

List of grouping set expressions. Only valid in the context of an aggregate GROUP BY expression list

ยง

Placeholder(Placeholder)

A place holder for parameters in a prepared statement (e.g. $foo or $1)

ยง

OuterReferenceColumn(DataType, Column)

A place holder which hold a reference to a qualified field in the outer query, used for correlated sub queries.

ยง

Unnest(Unnest)

Unnest expression

Implementationsยง

Sourceยง

impl Expr

Source

pub fn display_name(&self) -> Result<String, DataFusionError>

๐Ÿ‘ŽDeprecated since 40.0.0: use schema_name instead
Source

pub fn schema_name(&self) -> impl Display

The name of the column (field) that this Expr will produce.

For example, for a projection (e.g. SELECT <expr>) the resulting arrow Schema will have a field with this name.

Note that the resulting string is subtlety different from the Display representation for certain Expr. Some differences:

  1. Expr::Alias, which shows only the alias itself
  2. Expr::Cast / Expr::TryCast, which only displays the expression
ยงExample
let expr = col("foo").eq(lit(42));
assert_eq!("foo = Int32(42)", expr.schema_name().to_string());

let expr = col("foo").alias("bar").eq(lit(11));
assert_eq!("bar = Int32(11)", expr.schema_name().to_string());
Source

pub fn qualified_name(&self) -> (Option<TableReference>, String)

Returns the qualifier and the schema name of this expression.

Used when the expression forms the output field of a certain plan. The result is the fieldโ€™s qualifier and field name in the planโ€™s output schema. We can use this qualified name to reference the field.

Source

pub fn canonical_name(&self) -> String

๐Ÿ‘ŽDeprecated: use format! instead

Returns a full and complete string representation of this expression.

Source

pub fn variant_name(&self) -> &str

Return String representation of the variant represented by self Useful for non-rust based bindings

Source

pub fn eq(self, other: Expr) -> Expr

Return self == other

Source

pub fn not_eq(self, other: Expr) -> Expr

Return self != other

Source

pub fn gt(self, other: Expr) -> Expr

Return self > other

Source

pub fn gt_eq(self, other: Expr) -> Expr

Return self >= other

Source

pub fn lt(self, other: Expr) -> Expr

Return self < other

Source

pub fn lt_eq(self, other: Expr) -> Expr

Return self <= other

Source

pub fn and(self, other: Expr) -> Expr

Return self && other

Source

pub fn or(self, other: Expr) -> Expr

Return self || other

Source

pub fn like(self, other: Expr) -> Expr

Return self LIKE other

Source

pub fn not_like(self, other: Expr) -> Expr

Return self NOT LIKE other

Source

pub fn ilike(self, other: Expr) -> Expr

Return self ILIKE other

Source

pub fn not_ilike(self, other: Expr) -> Expr

Return self NOT ILIKE other

Source

pub fn name_for_alias(&self) -> Result<String, DataFusionError>

Return the name to use for the specific Expr

Source

pub fn alias_if_changed( self, original_name: String, ) -> Result<Expr, DataFusionError>

Ensure expr has the name as original_name by adding an alias if necessary.

Source

pub fn alias(self, name: impl Into<String>) -> Expr

Return self AS name alias expression

Source

pub fn alias_qualified( self, relation: Option<impl Into<TableReference>>, name: impl Into<String>, ) -> Expr

Return self AS name alias expression with a specific qualifier

Source

pub fn unalias(self) -> Expr

Remove an alias from an expression if one exists.

If the expression is not an alias, the expression is returned unchanged. This method does not remove aliases from nested expressions.

ยงExample
// `foo as "bar"` is unaliased to `foo`
let expr = col("foo").alias("bar");
assert_eq!(expr.unalias(), col("foo"));

// `foo as "bar" + baz` is not unaliased
let expr = col("foo").alias("bar") + col("baz");
assert_eq!(expr.clone().unalias(), expr);

// `foo as "bar" as "baz" is unalaised to foo as "bar"
let expr = col("foo").alias("bar").alias("baz");
assert_eq!(expr.unalias(), col("foo").alias("bar"));
Source

pub fn unalias_nested(self) -> Transformed<Expr>

Recursively removed potentially multiple aliases from an expression.

This method removes nested aliases and returns Transformed to signal if the expression was changed.

ยงExample
// `foo as "bar"` is unaliased to `foo`
let expr = col("foo").alias("bar");
assert_eq!(expr.unalias_nested().data, col("foo"));

// `foo as "bar" + baz` is  unaliased
let expr = col("foo").alias("bar") + col("baz");
assert_eq!(expr.clone().unalias_nested().data, col("foo") + col("baz"));

// `foo as "bar" as "baz" is unalaised to foo
let expr = col("foo").alias("bar").alias("baz");
assert_eq!(expr.unalias_nested().data, col("foo"));
Source

pub fn in_list(self, list: Vec<Expr>, negated: bool) -> Expr

Return self IN <list> if negated is false, otherwise return self NOT IN <list>.a

Source

pub fn is_null(self) -> Expr

Return `IsNull(Box(self))

Source

pub fn is_not_null(self) -> Expr

Return `IsNotNull(Box(self))

Source

pub fn sort(self, asc: bool, nulls_first: bool) -> Sort

Create a sort configuration from an existing expression.

let sort_expr = col("foo").sort(true, true); // SORT ASC NULLS_FIRST
Source

pub fn is_true(self) -> Expr

Return IsTrue(Box(self))

Source

pub fn is_not_true(self) -> Expr

Return IsNotTrue(Box(self))

Source

pub fn is_false(self) -> Expr

Return IsFalse(Box(self))

Source

pub fn is_not_false(self) -> Expr

Return IsNotFalse(Box(self))

Source

pub fn is_unknown(self) -> Expr

Return IsUnknown(Box(self))

Source

pub fn is_not_unknown(self) -> Expr

Return IsNotUnknown(Box(self))

Source

pub fn between(self, low: Expr, high: Expr) -> Expr

return self BETWEEN low AND high

Source

pub fn not_between(self, low: Expr, high: Expr) -> Expr

return self NOT BETWEEN low AND high

Source

pub fn try_into_col(&self) -> Result<Column, DataFusionError>

๐Ÿ‘ŽDeprecated since 39.0.0: use try_as_col instead
Source

pub fn try_as_col(&self) -> Option<&Column>

Return a reference to the inner Column if any

returns None if the expression is not a Column

Note: None may be returned for expressions that are not Column but are convertible to Column such as Cast expressions.

Example

use datafusion_expr::{col, Expr};
let expr = col("foo");
assert_eq!(expr.try_as_col(), Some(&Column::from("foo")));

let expr = col("foo").alias("bar");
assert_eq!(expr.try_as_col(), None);
Source

pub fn get_as_join_column(&self) -> Option<&Column>

Returns the inner Column if any. This is a specialized version of Self::try_as_col that take Cast expressions into account when the expression is as on condition for joins.

Called this method when you are sure that the expression is a Column or a Cast expression that wraps a Column.

Source

pub fn to_columns(&self) -> Result<HashSet<Column>, DataFusionError>

๐Ÿ‘ŽDeprecated since 40.0.0: use Expr::column_refs instead

Return all referenced columns of this expression.

Source

pub fn column_refs(&self) -> HashSet<&Column>

Return all references to columns in this expression.

ยงExample
// For an expression `a + (b * a)`
let expr = col("a") + (col("b") * col("a"));
let refs = expr.column_refs();
// refs contains "a" and "b"
assert_eq!(refs.len(), 2);
assert!(refs.contains(&Column::new_unqualified("a")));
assert!(refs.contains(&Column::new_unqualified("b")));
Source

pub fn add_column_refs<'a>(&'a self, set: &mut HashSet<&'a Column>)

Adds references to all columns in this expression to the set

See Self::column_refs for details

Source

pub fn column_refs_counts(&self) -> HashMap<&Column, usize>

Return all references to columns and their occurrence counts in the expression.

ยงExample
// For an expression `a + (b * a)`
let expr = col("a") + (col("b") * col("a"));
let mut refs = expr.column_refs_counts();
// refs contains "a" and "b"
assert_eq!(refs.len(), 2);
assert_eq!(*refs.get(&Column::new_unqualified("a")).unwrap(), 2);
assert_eq!(*refs.get(&Column::new_unqualified("b")).unwrap(), 1);
Source

pub fn add_column_ref_counts<'a>(&'a self, map: &mut HashMap<&'a Column, usize>)

Adds references to all columns and their occurrence counts in the expression to the map.

See Self::column_refs_counts for details

Source

pub fn any_column_refs(&self) -> bool

Returns true if there are any column references in this Expr

Source

pub fn contains_outer(&self) -> bool

Return true when the expression contains out reference(correlated) expressions.

Source

pub fn is_volatile_node(&self) -> bool

Returns true if the expression node is volatile, i.e. whether it can return different results when evaluated multiple times with the same input. Note: unlike Self::is_volatile, this function does not consider inputs:

  • rand() returns true,
  • a + rand() returns false
Source

pub fn is_volatile(&self) -> Result<bool, DataFusionError>

Returns true if the expression is volatile, i.e. whether it can return different results when evaluated multiple times with the same input.

Source

pub fn infer_placeholder_types( self, schema: &DFSchema, ) -> Result<Expr, DataFusionError>

Recursively find all Expr::Placeholder expressions, and to infer their DataType from the context of their use.

For example, gicen an expression like <int32> = $0 will infer $0 to have type int32.

Source

pub fn short_circuits(&self) -> bool

Returns true if some of this exprs subexpressions may not be evaluated and thus any side effects (like divide by zero) may not be encountered

Source

pub fn hash_node<H>(&self, hasher: &mut H)
where H: Hasher,

Hashes the direct content of an Expr without recursing into its children.

This method is useful to incrementally compute hashes, such as in CommonSubexprEliminate which builds a deep hash of a node and its descendants during the bottom-up phase of the first traversal and so avoid computing the hash of the node and then the hash of its descendants separately.

If a node doesnโ€™t have any children then this method is similar to .hash(), but not necessarily returns the same value.

As it is pretty easy to forget changing this method when Expr changes the implementation doesnโ€™t use wildcard patterns (.., _) to catch changes compile time.

Trait Implementationsยง

Sourceยง

impl Add for Expr

Support <expr> + <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the + operator.
Sourceยง

fn add(self, rhs: Expr) -> Expr

Performs the + operation. Read more
Sourceยง

impl BitAnd for Expr

Support <expr> & <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the & operator.
Sourceยง

fn bitand(self, rhs: Expr) -> Expr

Performs the & operation. Read more
Sourceยง

impl BitOr for Expr

Support <expr> | <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the | operator.
Sourceยง

fn bitor(self, rhs: Expr) -> Expr

Performs the | operation. Read more
Sourceยง

impl BitXor for Expr

Support <expr> ^ <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the ^ operator.
Sourceยง

fn bitxor(self, rhs: Expr) -> Expr

Performs the ^ operation. Read more
Sourceยง

impl Clone for Expr

Sourceยง

fn clone(&self) -> Expr

Returns a copy of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for Expr

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Default for Expr

Sourceยง

fn default() -> Expr

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl Display for Expr

Format expressions for display as part of a logical plan. In many cases, this will produce similar output to Expr.name() except that column names will be prefixed with โ€˜#โ€™.

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Div for Expr

Support <expr> / <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the / operator.
Sourceยง

fn div(self, rhs: Expr) -> Expr

Performs the / operation. Read more
Sourceยง

impl ExprFunctionExt for Expr

Sourceยง

fn order_by(self, order_by: Vec<Sort>) -> ExprFuncBuilder

Add ORDER BY <order_by>
Sourceยง

fn filter(self, filter: Expr) -> ExprFuncBuilder

Add FILTER <filter>
Sourceยง

fn distinct(self) -> ExprFuncBuilder

Add DISTINCT
Sourceยง

fn null_treatment( self, null_treatment: impl Into<Option<NullTreatment>>, ) -> ExprFuncBuilder

Add RESPECT NULLS or IGNORE NULLS
Sourceยง

fn partition_by(self, partition_by: Vec<Expr>) -> ExprFuncBuilder

Add PARTITION BY
Sourceยง

fn window_frame(self, window_frame: WindowFrame) -> ExprFuncBuilder

Add appropriate window frame conditions
Sourceยง

impl ExprSchemable for Expr

Sourceยง

fn get_type(&self, schema: &dyn ExprSchema) -> Result<DataType, DataFusionError>

Returns the arrow::datatypes::DataType of the expression based on ExprSchema

Note: DFSchema implements ExprSchema.

ยงExamples

Get the type of an expression that adds 2 columns. Adding an Int32 and Float32 results in Float32 type


fn main() {
  let expr = col("c1") + col("c2");
  let schema = DFSchema::from_unqualified_fields(
    vec![
      Field::new("c1", DataType::Int32, true),
      Field::new("c2", DataType::Float32, true),
      ].into(),
      HashMap::new(),
  ).unwrap();
  assert_eq!("Float32", format!("{}", expr.get_type(&schema).unwrap()));
}
ยง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]).

Sourceยง

fn nullable( &self, input_schema: &dyn ExprSchema, ) -> Result<bool, DataFusionError>

Returns the nullability of the expression based on ExprSchema.

Note: DFSchema implements ExprSchema.

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

Sourceยง

fn data_type_and_nullable( &self, schema: &dyn ExprSchema, ) -> Result<(DataType, bool), DataFusionError>

Returns the datatype and nullability of the expression based on ExprSchema.

Note: DFSchema implements ExprSchema.

ยงErrors

This function errors when it is not possible to compute its datatype or nullability.

Sourceยง

fn to_field( &self, input_schema: &dyn ExprSchema, ) -> Result<(Option<TableReference>, Arc<Field>), DataFusionError>

Returns a arrow::datatypes::Field compatible with this expression.

So for example, a projected expression col(c1) + col(c2) is placed in an output field named col(โ€œc1 + c2โ€)

Sourceยง

fn cast_to( self, cast_to_type: &DataType, schema: &dyn ExprSchema, ) -> Result<Expr, DataFusionError>

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.

Sourceยง

fn metadata( &self, schema: &dyn ExprSchema, ) -> Result<HashMap<String, String>, DataFusionError>

given a schema, return the exprโ€™s optional metadata
Sourceยง

impl FieldAccessor for Expr

Sourceยง

fn field(self, name: impl Literal) -> Expr

Sourceยง

impl<'a> From<(Option<&'a TableReference>, &'a Arc<Field>)> for Expr

Create an Expr from an optional qualifier and a FieldRef. This is useful for creating Expr from a DFSchema.

See example on Expr

Sourceยง

fn from(value: (Option<&'a TableReference>, &'a Arc<Field>)) -> Expr

Converts to this type from the input type.
Sourceยง

impl From<Column> for Expr

Create an Expr from a Column

Sourceยง

fn from(value: Column) -> Expr

Converts to this type from the input type.
Sourceยง

impl Hash for Expr

Sourceยง

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 ยท Sourceยง

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Sourceยง

impl IndexAccessor for Expr

Sourceยง

fn index(self, key: Expr) -> Expr

Sourceยง

impl Mul for Expr

Support <expr> * <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the * operator.
Sourceยง

fn mul(self, rhs: Expr) -> Expr

Performs the * operation. Read more
Sourceยง

impl Neg for Expr

Support - <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the - operator.
Sourceยง

fn neg(self) -> <Expr as Neg>::Output

Performs the unary - operation. Read more
Sourceยง

impl Not for Expr

Support NOT <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the ! operator.
Sourceยง

fn not(self) -> <Expr as Not>::Output

Performs the unary ! operation. Read more
Sourceยง

impl PartialEq for Expr

Sourceยง

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl PartialOrd for Expr

Sourceยง

fn partial_cmp(&self, other: &Expr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 ยท Sourceยง

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 ยท Sourceยง

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 ยท Sourceยง

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 ยท Sourceยง

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Sourceยง

impl Rem for Expr

Support <expr> % <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the % operator.
Sourceยง

fn rem(self, rhs: Expr) -> Expr

Performs the % operation. Read more
Sourceยง

impl Shl for Expr

Support <expr> << <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the << operator.
Sourceยง

fn shl(self, rhs: Expr) -> <Expr as Shl>::Output

Performs the << operation. Read more
Sourceยง

impl Shr for Expr

Support <expr> >> <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the >> operator.
Sourceยง

fn shr(self, rhs: Expr) -> <Expr as Shr>::Output

Performs the >> operation. Read more
Sourceยง

impl SliceAccessor for Expr

Sourceยง

fn range(self, start: Expr, stop: Expr) -> Expr

Sourceยง

impl Sub for Expr

Support <expr> - <expr> fluent style

Sourceยง

type Output = Expr

The resulting type after applying the - operator.
Sourceยง

fn sub(self, rhs: Expr) -> Expr

Performs the - operation. Read more
Sourceยง

impl TreeNode for Expr

Sourceยง

fn apply_children<'n, F>( &'n self, f: F, ) -> Result<TreeNodeRecursion, DataFusionError>

Low-level API used to implement other APIs. Read more
Sourceยง

fn map_children<F>(self, f: F) -> Result<Transformed<Expr>, DataFusionError>

Low-level API used to implement other APIs. Read more
Sourceยง

fn visit<'n, V>( &'n self, visitor: &mut V, ) -> Result<TreeNodeRecursion, DataFusionError>
where V: TreeNodeVisitor<'n, Node = Self>,

Visit the tree node with a TreeNodeVisitor, performing a depth-first walk of the node and its children. Read more
Sourceยง

fn rewrite<R>( self, rewriter: &mut R, ) -> Result<Transformed<Self>, DataFusionError>
where R: TreeNodeRewriter<Node = Self>,

Rewrite the tree node with a TreeNodeRewriter, performing a depth-first walk of the node and its children. Read more
Sourceยง

fn apply<'n, F>(&'n self, f: F) -> Result<TreeNodeRecursion, DataFusionError>

Applies f to the node then each of its children, recursively (a top-down, pre-order traversal). Read more
Sourceยง

fn transform<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
where F: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

Recursively rewrite the nodeโ€™s children and then the node using f (a bottom-up post-order traversal). Read more
Sourceยง

fn transform_down<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
where F: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

Recursively rewrite the tree using f in a top-down (pre-order) fashion. Read more
Sourceยง

fn transform_down_mut<F>( self, f: &mut F, ) -> Result<Transformed<Self>, DataFusionError>
where F: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

๐Ÿ‘ŽDeprecated since 38.0.0: Use transform_down instead
Same as Self::transform_down but with a mutable closure.
Sourceยง

fn transform_up<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
where F: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

Recursively rewrite the node using f in a bottom-up (post-order) fashion. Read more
Sourceยง

fn transform_up_mut<F>( self, f: &mut F, ) -> Result<Transformed<Self>, DataFusionError>
where F: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

๐Ÿ‘ŽDeprecated since 38.0.0: Use transform_up instead
Same as Self::transform_up but with a mutable closure.
Sourceยง

fn transform_down_up<FD, FU>( self, f_down: FD, f_up: FU, ) -> Result<Transformed<Self>, DataFusionError>
where FD: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>, FU: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,

Transforms the node using f_down while traversing the tree top-down (pre-order), and using f_up while traversing the tree bottom-up (post-order). Read more
Sourceยง

fn exists<F>(&self, f: F) -> Result<bool, DataFusionError>
where F: FnMut(&Self) -> Result<bool, DataFusionError>,

Returns true if f returns true for any node in the tree. Read more
Sourceยง

impl Eq for Expr

Sourceยง

impl StructuralPartialEq for Expr

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dst: *mut T)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T> ToString for T
where T: Display + ?Sized,

Sourceยง

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

Sourceยง

impl<T> MaybeSendSync for T

Sourceยง

impl<M> Measure for M
where M: Debug + PartialOrd + Add<Output = M> + Default + Clone,

Sourceยง

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,