Module datafusion::logical_expr
source · Expand description
re-export of datafusion_expr
crate
Modules
- Aggregate function module contains all built-in aggregate functions definitions
- Conditional expressions
- Expr module contains core type definition for
Expr
. - Functions for creating logical expressions
- Expression rewriter
- Utility functions for complex field access
- Function module contains typing and signature for built-in and user defined functions.
- Tree node implementation for logical expr and logical plan
- Type coercion rules for DataFusion
- Expression utilities
- Window frame module
- Window functions provide the ability to perform calculations across sets of rows that are related to the current query row.
- Structures used to hold window function state (for implementing WindowUDFs)
Macros
Structs
- Aggregates its input based on a set of grouping and aggregate expressions (e.g. SUM).
- Logical representation of a user-defined aggregate function (UDAF).
- Runs the actual plan, and then prints the physical plan with with execution metrics.
- BETWEEN expression
- Binary expression
- CASE expression
- Cast expression
- Creates a catalog (aka “Database”).
- Creates a schema.
- Creates an external table.
- Creates an in memory table.
- Creates a view.
- Apply Cross Join to two logical plans
- Describe the schema of table
- Removes duplicate rows from the input
- The operator that modifies the content of a database (adapted from substrait WriteRel)
- Drops a schema
- Drops a table.
- Drops a view.
- Produces no rows: An empty relation with an empty schema
- Produces a relation with string representations of various parts of the plan
- Extension operator defined outside of DataFusion
- Filters rows from its input that do not match an expression (essentially a WHERE clause with a predicate expression).
- Returns the field of a
arrow::array::ListArray
orarrow::array::StructArray
by key - Join two logical plans on one or more join columns
- LIKE expression
- Produces the first
n
tuples from its input and discards the rest. - Builder for logical plans
- Prepare a statement but do not execute it. Prepare statements can have 0 or more
Expr::Placeholder
expressions that are filled in during execution - Evaluates an arbitrary list of expressions (essentially a SELECT with an expression list) on its input.
- Repartition the plan based on a partitioning scheme.
- Logical representation of a UDF.
- Set a Variable’s value – value in
ConfigOptions
- The signature of a function defines the supported argument types and its volatility.
- Sorts its input according to a list of sort expressions.
- Represents some sort of execution plan, in String form
- Subquery
- Aliased subquery
- Produces rows from a table provider by reference or from the context
- Indicator that any current transaction should be terminated
- Indicator that the following statements should be committed or rolled back atomically
- TryCast Expression
- Union multiple inputs
- Unnest a column that contains a nested list type.
- Values expression. See Postgres VALUES documentation for more details.
- Window its input based on a set of window spec and window function (e.g. SUM or RANK)
- The frame-spec determines which output rows are read by an aggregate window function.
- Logical representation of a user-defined window function (UDWF) A UDWF is different from a UDF in that it is stateful across batches.
Enums
- Enum of all built-in aggregate functions
- A window function built in to DataFusion
- Enum of all built-in scalar functions
- Represents the result of evaluating an expression: either a single
ScalarValue
or anArrayRef
. - Various types of DDL (CREATE / DROP) catalog manipulation
Expr
is a central struct of DataFusion’s query API, and represent logical expressions such asA + 1
, orCAST(c1 AS int)
.- Grouping sets See https://www.postgresql.org/docs/current/queries-table-expressions.html#QUERIES-GROUPING-SETS for Postgres definition. See https://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-groupby.html for Apache Spark definition.
- Join constraint
- Join type
- A LogicalPlan represents the different types of relational operators (such as Projection, Filter, etc) and can be created by the SQL query planner and the DataFrame API.
- Operators applied to expressions
- Logical partitioning schemes supported by the repartition operator.
- Represents which type of plan, when storing multiple for use in EXPLAIN plans
- Various types of Statements.
- Indicates whether and how a filter expression can be handled by a TableProvider for table scans.
- Indicates the type of this table for metadata/catalog purposes.
- Indicates if this transaction is allowed to write
- Indicates if a transaction was committed or aborted
- Indicates ANSI transaction isolation level
- A function’s type signature, which defines the function’s supported argument types.
- A function’s volatility, which defines the functions eligibility for certain optimizations
- There are five ways to describe starting and ending frame boundaries:
- There are three frame types: ROWS, GROUPS, and RANGE. The frame type determines how the starting and ending boundaries of the frame are measured.
- WindowFunction
Constants
- Default table name for unnamed table
Statics
- Currently supported types by the nullif function. The order of these types correspond to the order on which coercion applies This should thus be from least informative to most informative
Traits
- Describes an aggregate functions’s state.
- trait to allow expr to typable with respect to a schema
- Trait for converting a type to a
Literal
literal expression. - Partition evaluator for Window Functions
- The TableSource trait is used during logical query planning and optimizations and provides access to schema information and filter push-down capabilities. This trait provides a subset of the functionality of the TableProvider trait in the core datafusion crate. The TableProvider trait provides additional capabilities needed for physical query execution (such as the ability to perform a scan). The reason for having two separate traits is to avoid having the logical plan code be dependent on the DataFusion execution engine. Other projects may want to use DataFusion’s logical plans and have their own execution engine.
- Trait for converting a type to a literal timestamp
- Trait for something that can be formatted as a stringified plan
- This defines the interface for
LogicalPlan
nodes that can be used to extend DataFusion with custom relational operators. - This trait facilitates implementation of the
UserDefinedLogicalNode
.
Functions
- absolute value
- inverse cosine
- inverse hyperbolic cosine
- Return a new expression with a logical AND
- Returns the approximate number of distinct input values. This function provides an approximation of count(DISTINCT x). Zero is returned if all input values are null. This function should produce a standard error of 0.81%, which is the standard deviation of the (approximately normal) error distribution over all possible sets. It does not guarantee an upper bound on the error for any specific input set.
- Calculate an approximation of the median for
expr
. - Calculate an approximation of the specified
percentile
forexpr
. - Calculate an approximation of the specified
percentile
forexpr
andweight_expr
. - returns an Arrow array using the specified input expressions.
- appends an element to the end of an array.
- concatenates arrays.
- returns true, if each element of the second array appearing in the first array, otherwise false.
- returns an array of the array’s dimensions.
- returns an array filled with copies of the given value.
- returns the length of the array dimension.
- returns the number of dimensions of the array.
- searches for an element in the array, returns first occurrence.
- searches for an element in the array, returns all occurrences.
- prepends an element to the beginning of an array.
- removes all elements equal to the given value from the array.
- replaces a specified element with another specified element.
- converts each element to its text representation.
- data type
- ASCII code value of the character
- inverse sine
- inverse hyperbolic sine
- inverse tangent
- inverse tangent of a division given in the argument
- inverse hyperbolic tangent
- Create an expression to represent the avg() aggregate function
- Return a new expression
left <op> right
- the number of bits in the
string
- Return a new expression with bitwise AND
- Return a new expression with bitwise OR
- Return a new expression with bitwise SHIFT LEFT
- Return a new expression with bitwise SHIFT RIGHT
- Return a new expression with bitwise XOR
- removes all characters, spaces by default, from both sides of a string
- Creates a schema for a join operation. The fields from the left side are first
- Calls a named built in function
- returns the total number of elements in the array.
- Create a CASE WHEN statement with literal WHEN expressions for comparison to the base expression.
- Create a cast expression
- cube root of a number
- nearest integer greater than or equal to argument
- the number of characters in the
string
- converts the Unicode code point to a UTF8 character
- returns
coalesce(args...)
, which evaluates to the value of the first Expr which is not NULL - Create a column expression based on a qualified or unqualified column name. Will normalize unquoted identifiers according to SQL rules (identifiers will become lowercase).
- Concatenates the text representations of all the arguments. NULL arguments are ignored.
- concatenates several strings
- Concatenates all but the first argument, with separators. The first argument is used as the separator. NULL arguments in
values
are ignored. - concatenates several strings, placing a seperator between each one
- cosine
- hyperbolic cosine
- cotangent
- Create an expression to represent the count() aggregate function
- Create an expression to represent the count(distinct) aggregate function
- Creates a new UDAF with a specific signature, state type and return type. The signature and state type must match the
Accumulator's implementation
. - Creates a new UDF with a specific signature and specific return type. This is a helper function to create a new UDF. The function
create_udf
returns a subset of all possibleScalarFunction
: - Creates a new UDWF with a specific signature, state type and return type.
- Create a grouping set for all combination of
exprs
- returns current UTC date as a
DataType::Date32
value - returns current UTC time as a
DataType::Time64
value - coerces an arbitrary timestamp to the start of the nearest specified interval
- extracts a subfield from the date
- truncates the date to a specified level of precision
- decode the
input
, using theencoding
. encoding can be base64 or hex - converts radians to degrees
- compute the binary hash of
input
, using thealgorithm
- Print the schema in a compact representation to
buf
- encode the
input
, using theencoding
. encoding can be base64 or hex - Create an EXISTS subquery expression
- exponential
- factorial
- nearest integer less than or equal to argument
- returns the unix time in format
- greatest common divisor
- Create a grouping set
- Create an unqualified column expression from the provided name, without normalizing the column.
- Create an in_list expression
- Create an IN subquery expression
- converts the first letter of each word in
string
in uppercase and the remaining characters in lowercase - Create is false expression
- Create is not false expression
- Create is not true expression
- Create is not unknown expression
- Create is null expression
- Create is true expression
- Create is unknown expression
- least common multiple
- returns the first
n
characters in thestring
- Create a literal expression
- Create a literal timestamp expression
- natural logarithm
- logarithm of a
x
for a particularbase
- base 2 logarithm
- base 10 logarithm
- convert the string to lower case
- fill up a string to the length by prepending the characters
- removes all characters, spaces by default, from the beginning of a string
- Create an expression to represent the max() aggregate function
- returns the MD5 hash of a string
- Calculate the median for
expr
. - Create an expression to represent the min() aggregate function
- Create a NOT EXISTS subquery expression
- Create a NOT IN subquery expression
- returns current timestamp in nanoseconds, using the same value for all instances of now() in same statement
- returns NULL if value1 equals value2; otherwise it returns value1. This can be used to perform the inverse operation of the COALESCE expression.
- returns the number of bytes of a string
- Return a new expression with a logical OR
- Create an out reference column which hold a reference that has been resolved to a field outside of the current plan.
- Returns an approximate value of π
base
raised to the power ofexponent
- converts degrees to radians
- Returns a random value in the range 0.0 <= x < 1.0
- matches a regular expression against a string and returns matched substrings.
- replace strings that match a regular expression
- repeats the
string
ton
times - replaces all occurrences of
from
withto
in thestring
- reverses the
string
- returns the last
n
characters in thestring
- Create a grouping set for rollup
- round to nearest integer
- fill up a string to the length by appending the characters
- removes all characters, spaces by default, from the end of a string
- Create a scalar subquery expression
- SHA-224 hash
- SHA-256 hash
- SHA-384 hash
- SHA-512 hash
- sign of the argument (-1, 0, +1)
- sine
- hyperbolic sine
- splits a string based on a delimiter and picks out the desired field based on the index.
- square root of a number
- whether the
string
starts with theprefix
- Create an expression to represent the stddev() aggregate function
- finds the position from where the
substring
matches thestring
- substring from the
position
to the end - substring from the
position
withlength
characters - Create an expression to represent the sum() aggregate function
- Create a LogicalPlanBuilder representing a scan of a table with the provided name and schema. This is mostly used for testing and documentation.
- tangent
- hyperbolic tangent
- returns the hexdecimal representation of an integer
- converts a string to a
Timestamp(Microseconds, None)
- converts a string to a
Timestamp(Milliseconds, None)
- converts a string to a
Timestamp(Seconds, None)
- replaces the characters in
from
with the counterpart into
- removes all characters, space by default from the string
- removes the last n elements from the array.
- truncate toward zero, with optional precision
- Create a try cast expression
- Union two logical plans.
- converts the string to upper case
- returns uuid v4 as a string value
- Create a CASE WHEN statement with boolean WHEN expressions and no base expression.
- Wrap projection for a plan, if the join keys contains normal expression.
Type Definitions
- Factory that returns an accumulator for the given aggregate, given its return datatype.
- Factory that creates a PartitionEvaluator for the given window function
- Factory that returns the functions’s return type given the input argument types
- Scalar function
- Factory that returns the types used by an aggregator to serialize its state, given its return datatype.