Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 31 variants Column(ColumnRef), Literal(LiteralValue), Not(Box<Expr>), IsNull(Box<Expr>), IsNotNull(Box<Expr>), Cast { expr: Box<Expr>, target_type: DataType, }, TryCast { expr: Box<Expr>, target_type: DataType, }, Binary { left: Box<Expr>, op: BinaryOp, right: Box<Expr>, output_type: Option<DataType>, }, Like { expr: Box<Expr>, pattern: String, escape: Option<String>, negated: bool, }, Substring { expr: Box<Expr>, start: i32, length: Option<i32>, }, Lower(Box<Expr>), Upper(Box<Expr>), Trim { expr: Box<Expr>, trim_chars: String, }, LTrim { expr: Box<Expr>, trim_chars: String, }, RTrim { expr: Box<Expr>, trim_chars: String, }, StringContains { expr: Box<Expr>, pattern: String, }, StartsWith { expr: Box<Expr>, prefix: String, }, EndsWith { expr: Box<Expr>, suffix: String, }, StringLength { expr: Box<Expr>, unit: StringLengthUnit, output_type: DataType, }, RegexpReplace { expr: Box<Expr>, pattern: String, replacement: String, output_type: DataType, }, Concat(Vec<Expr>), Abs(Box<Expr>), UnaryMath { op: UnaryMathOp, expr: Box<Expr>, output_type: DataType, }, Round { expr: Box<Expr>, decimal_places: i32, output_type: DataType, }, InList { expr: Box<Expr>, list: Vec<Expr>, negated: bool, }, IsDistinctFrom { left: Box<Expr>, right: Box<Expr>, }, IsNotDistinctFrom { left: Box<Expr>, right: Box<Expr>, }, Case { branches: Vec<CaseWhen>, else_expr: Box<Expr>, }, Extract { field: DatePart, expr: Box<Expr>, }, DateTrunc { field: DatePart, expr: Box<Expr>, output_type: DataType, }, Alias { expr: Box<Expr>, alias: String, },
}
Expand description

Scalar expression IR used by native query-plan nodes.

Expr describes logical expression structure independently of DataFusion’s physical-expression APIs. It is intentionally compact: it names input columns, literals, SQL-style predicates, scalar operations, and aliases that a native executor or validator can either lower directly or reject with a structured diagnostic. The Display implementation is part of the human-readable diagnostics contract; keep it stable unless the displayed IR is misleading.

Variants§

§

Column(ColumnRef)

A column reference resolved against the current node input schema.

§

Literal(LiteralValue)

A typed literal value.

§

Not(Box<Expr>)

SQL NOT; a null operand yields null.

§

IsNull(Box<Expr>)

SQL IS NULL; the result is never null.

§

IsNotNull(Box<Expr>)

SQL IS NOT NULL; the result is never null.

§

Cast

Explicit cast to an Arrow data type.

Fields

§expr: Box<Expr>

Expression whose result is cast.

§target_type: DataType

Desired output type after the cast.

§

TryCast

SQL TRY_CAST to an Arrow data type. Rows whose value cannot be represented in target_type evaluate to null and do not raise an error.

Native execution currently admits only Utf8 → integer targets; other type pairs are rejected during validation/lowering.

Fields

§expr: Box<Expr>

Expression whose result is try-cast.

§target_type: DataType

Desired output type after the try-cast.

§

Binary

Binary infix operation such as arithmetic, comparison, or boolean logic.

Fields

§left: Box<Expr>

Left operand.

§op: BinaryOp

Operation to apply.

§right: Box<Expr>

Right operand.

§output_type: Option<DataType>

Optional declared output type for operators whose result type is a frontend contract. The native backend cannot infer that type from operands alone.

§

Like

SQL LIKE or NOT LIKE string predicate.

Fields

§expr: Box<Expr>

String expression being matched.

§pattern: String

SQL LIKE pattern. % and _ keep their SQL wildcard meaning.

§escape: Option<String>

Optional SQL escape marker. None means no explicit escape clause.

§negated: bool

true for NOT LIKE; false for LIKE.

§

Substring

SQL substring expression.

Current native support uses a one-based start with start >= 1. When length is present, it must be nonnegative and (start - 1) + length must fit in i32.

Fields

§expr: Box<Expr>

String expression being sliced.

§start: i32

One-based start position. Current native execution requires start >= 1.

§length: Option<i32>

Optional character count. When present, it must be nonnegative and (start - 1) + length must fit in i32.

§

Lower(Box<Expr>)

SQL LOWER; requires a string input and keeps its type.

§

Upper(Box<Expr>)

SQL UPPER; requires a string input and keeps its type.

§

Trim

SQL TRIM(trim_chars FROM expr).

trim_chars is a set: every leading or trailing character that appears in it is removed. An empty set is the identity. The DataFusion frontend lowers the one-argument SQL form with a single space and omits the node when the set is empty.

Fields

§expr: Box<Expr>

String expression trimmed at both ends.

§trim_chars: String

Characters removed from both ends.

§

LTrim

Leading-only form of Self::Trim, with the same set semantics.

Fields

§expr: Box<Expr>

String expression trimmed at its start.

§trim_chars: String

Characters removed from the start.

§

RTrim

Trailing-only form of Self::Trim, with the same set semantics.

Fields

§expr: Box<Expr>

String expression trimmed at its end.

§trim_chars: String

Characters removed from the end.

§

StringContains

Literal substring containment test.

Fields

§expr: Box<Expr>

String expression searched.

§pattern: String

Literal substring; wildcards have no meaning here.

§

StartsWith

Literal prefix test.

Fields

§expr: Box<Expr>

String expression tested.

§prefix: String

Literal prefix.

§

EndsWith

Literal suffix test.

Fields

§expr: Box<Expr>

String expression tested.

§suffix: String

Literal suffix.

§

StringLength

SQL CHARACTER_LENGTH(expr) or OCTET_LENGTH(expr) string expression.

Fields

§expr: Box<Expr>

String expression whose length is measured.

§unit: StringLengthUnit

Whether the length counts characters or UTF-8 bytes.

§output_type: DataType

Declared frontend output type.

§

RegexpReplace

SQL REGEXP_REPLACE(expr, pattern, replacement) string expression.

Fields

§expr: Box<Expr>

String expression being transformed.

§pattern: String

Regex pattern.

§replacement: String

Replacement template, including optional back-references.

§output_type: DataType

Declared frontend output type.

§

Concat(Vec<Expr>)

SQL CONCAT(expr, ...) string expression.

Native execution follows DataFusion semantics: null inputs contribute empty strings and do not produce a null output row.

§

Abs(Box<Expr>)

SQL ABS over a numeric input.

§

UnaryMath

SQL unary arithmetic or math function.

The output_type is the frontend-declared result type. It is part of the native contract because cudf’s expression builder can infer a physical type that still needs to be aligned with DataFusion’s exposed schema. Results follow IEEE 754: domain errors produce NaN or an infinity without raising an error, and null inputs produce null.

Fields

§op: UnaryMathOp

Function applied to each row.

§expr: Box<Expr>

Numeric expression the function is applied to.

§output_type: DataType

Declared output type after evaluation.

§

Round

SQL ROUND(expr, decimal_places) numeric expression.

The output_type is the frontend-declared DataFusion result type. It is part of the native contract because decimal ROUND may reduce scale even when the lower-level cuDF operation preserves the input storage type.

Fields

§expr: Box<Expr>

Numeric or decimal expression being rounded.

§decimal_places: i32

Number of decimal places. Half-way ties round away from zero.

§output_type: DataType

Declared output type after rounding.

§

InList

SQL IN or NOT IN membership predicate.

The IR can represent general SQL IN lists. Runnable native plans currently require a non-empty list of literal, non-null candidate values.

Fields

§expr: Box<Expr>

Expression whose value is compared with the list.

§list: Vec<Expr>

Candidate expressions in SQL list order. Runnable native plans currently require this list to be non-empty and contain only literal, non-null values.

§negated: bool

true for NOT IN; false for IN.

§

IsDistinctFrom

SQL IS DISTINCT FROM null-aware comparison.

Unlike ordinary inequality this always produces a non-null boolean: two nulls are not distinct, and exactly one null is distinct.

Fields

§left: Box<Expr>

Left comparison operand.

§right: Box<Expr>

Right comparison operand.

§

IsNotDistinctFrom

SQL IS NOT DISTINCT FROM null-aware comparison.

Unlike ordinary equality this always produces a non-null boolean: two nulls are not distinct and therefore compare true.

Fields

§left: Box<Expr>

Left comparison operand.

§right: Box<Expr>

Right comparison operand.

§

Case

Searched SQL CASE WHEN ... THEN ... ELSE ... END.

Fields

§branches: Vec<CaseWhen>

Ordered branches. The first branch whose predicate evaluates true is selected.

§else_expr: Box<Expr>

Result expression used when no branch predicate evaluates true.

§

Extract

SQL date/time field extraction.

Fields

§field: DatePart

Field to extract from the input expression.

§expr: Box<Expr>

Date, timestamp, or compatible temporal expression.

§

DateTrunc

SQL DATE_TRUNC(field, expr) expression.

Fields

§field: DatePart

Field to truncate the input expression to.

§expr: Box<Expr>

Timestamp expression being truncated.

§output_type: DataType

Declared frontend output type.

§

Alias

Output alias for projection and aggregate argument naming.

Fields

§expr: Box<Expr>

Expression being renamed.

§alias: String

Field name exposed to downstream schemas and diagnostics.

Implementations§

Source§

impl Expr

Source

pub fn children(&self) -> impl Iterator<Item = &Expr>

Direct child expressions in evaluation order.

Source

pub fn any(&self, predicate: impl FnMut(&Expr) -> bool) -> bool

Whether predicate holds for this expression or any expression below it, visited depth first.

Source

pub fn columns(&self) -> impl Iterator<Item = &ColumnRef>

Every column this expression references, in depth-first order.

Source

pub fn column(name: impl Into<String>) -> Self

Unqualified reference resolved by name against the node’s single input. Multi-input nodes use Self::input_column, since the same leaf name may appear on both sides.

Source

pub fn input_column( input: usize, name: impl Into<String>, display_name: impl Into<String>, ) -> Self

Build a column expression qualified by a positional input.

Use this for multi-input nodes such as joins, where equal leaf column names may appear on both sides. name is the source/input field name; display_name is the projected or user-visible name.

Source

pub fn literal(value: LiteralValue) -> Self

Typed literal; the Arrow type travels with the value.

Source

pub fn binary(left: Self, op: BinaryOp, right: Self) -> Self

Binary operation whose result type the backend infers from the operands. Use Self::binary_with_output_type when the frontend declares a type the backend cannot infer, such as a decimal division’s result scale.

Source

pub fn binary_with_output_type( left: Self, op: BinaryOp, right: Self, output_type: DataType, ) -> Self

Build a binary operation expression with a declared result type.

Source

pub fn logical_not(expr: Self) -> Self

SQL NOT; the Not operator impl builds the same node.

Source

pub fn is_null(expr: Self) -> Self

SQL IS NULL; the result is never null.

Source

pub fn is_not_null(expr: Self) -> Self

SQL IS NOT NULL; the result is never null.

Source

pub fn cast(expr: Self, target_type: DataType) -> Self

Explicit cast to target_type. See Self::try_cast for the form that yields null for values the target cannot represent.

Source

pub fn try_cast(expr: Self, target_type: DataType) -> Self

SQL TRY_CAST; native execution admits only Utf8 to integer targets.

Source

pub fn like(expr: Self, pattern: impl Into<String>) -> Self

SQL LIKE without an ESCAPE clause; % and _ are wildcards.

Source

pub fn not_like(expr: Self, pattern: impl Into<String>) -> Self

SQL NOT LIKE without an ESCAPE clause.

Source

pub fn like_escape( expr: Self, pattern: impl Into<String>, escape: impl Into<String>, ) -> Self

SQL LIKE ... ESCAPE escape; validation checks the escape clause before execution.

Source

pub fn not_like_escape( expr: Self, pattern: impl Into<String>, escape: impl Into<String>, ) -> Self

SQL NOT LIKE ... ESCAPE escape.

Source

pub fn substring(expr: Self, start: i32, length: Option<i32>) -> Self

Build a SQL substring expression.

Current native support requires start >= 1, nonnegative length when present, and (start - 1) + length to fit in i32.

Source

pub fn lower(expr: Self) -> Self

SQL LOWER; requires a string input and keeps its type.

Source

pub fn upper(expr: Self) -> Self

SQL UPPER; requires a string input and keeps its type.

Source

pub fn trim(expr: Self, trim_chars: impl Into<String>) -> Self

SQL TRIM(trim_chars FROM expr); see Self::Trim for the set semantics of trim_chars.

Source

pub fn ltrim(expr: Self, trim_chars: impl Into<String>) -> Self

Leading-only trim; see Self::Trim.

Source

pub fn rtrim(expr: Self, trim_chars: impl Into<String>) -> Self

Trailing-only trim; see Self::Trim.

Source

pub fn string_contains(expr: Self, pattern: impl Into<String>) -> Self

Boolean test that expr contains the literal pattern; no wildcard interpretation.

Source

pub fn starts_with(expr: Self, prefix: impl Into<String>) -> Self

Boolean test that expr starts with the literal prefix.

Source

pub fn ends_with(expr: Self, suffix: impl Into<String>) -> Self

Boolean test that expr ends with the literal suffix.

Source

pub fn string_length(expr: Self, output_type: DataType) -> Self

SQL CHARACTER_LENGTH with the frontend-declared output_type.

Source

pub fn octet_length(expr: Self, output_type: DataType) -> Self

SQL OCTET_LENGTH with the frontend-declared output_type.

Source

pub fn regexp_replace( expr: Self, pattern: impl Into<String>, replacement: impl Into<String>, output_type: DataType, ) -> Self

SQL REGEXP_REPLACE; replacement may contain back-references.

Source

pub fn concat(exprs: Vec<Self>) -> Self

SQL CONCAT; null inputs contribute empty strings, as in DataFusion.

Source

pub fn abs(expr: Self) -> Self

SQL ABS over a numeric input.

Source

pub fn unary_math(op: UnaryMathOp, expr: Self, output_type: DataType) -> Self

Unary math function with the frontend-declared output_type; see UnaryMathOp for the IEEE 754 domain behavior of each function.

Source

pub fn round(expr: Self, decimal_places: i32, output_type: DataType) -> Self

SQL ROUND; ties round away from zero, and output_type carries the decimal scale the frontend declared.

Source

pub fn in_list(expr: Self, list: Vec<Self>) -> Self

Build a SQL IN predicate.

The IR accepts expression candidates, but runnable native plans require a non-empty list of literal, non-null candidate values.

Source

pub fn not_in_list(expr: Self, list: Vec<Self>) -> Self

Build a SQL NOT IN predicate.

The IR accepts expression candidates, but runnable native plans require a non-empty list of literal, non-null candidate values.

Source

pub fn is_distinct_from(left: Self, right: Self) -> Self

Null-aware inequality; the result is never null.

Source

pub fn is_not_distinct_from(left: Self, right: Self) -> Self

Null-aware equality; the result is never null.

Source

pub fn case(branches: Vec<CaseWhen>, else_expr: Self) -> Self

Searched CASE. The IR requires an ELSE expression; a frontend supplies one for a SQL CASE that omits it.

Source

pub fn extract(field: DatePart, expr: Self) -> Self

SQL EXTRACT(field FROM expr); native execution supports the fields in DatePart::EXTRACT_FIELDS.

Source

pub fn date_trunc(field: DatePart, expr: Self, output_type: DataType) -> Self

SQL DATE_TRUNC; native execution supports the fields in DatePart::DATE_TRUNC_FIELDS.

Source

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

Renames the output field without changing evaluation. See [alias_wrapped_column] for the rename that stays zero-copy.

Source

pub fn contains_regexp_replace(&self) -> bool

Returns true when this expression tree contains a REGEXP_REPLACE.

Used by capability labeling and runtime preflight paths that size replace-with-backrefs via the owning cudf output-size contract.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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

Formats the value using the given formatter. Read more
Source§

impl Display for Expr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Not for Expr

Source§

type Output = Expr

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation using logical or bitwise negation. Read more
Source§

impl PartialEq for Expr

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> 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§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.