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
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
Binary
Binary infix operation such as arithmetic, comparison, or boolean logic.
Fields
Like
SQL LIKE or NOT LIKE string predicate.
Fields
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
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
LTrim
Leading-only form of Self::Trim, with the same set semantics.
Fields
RTrim
Trailing-only form of Self::Trim, with the same set semantics.
Fields
StringContains
Literal substring containment test.
Fields
StartsWith
Literal prefix test.
EndsWith
Literal suffix test.
StringLength
SQL CHARACTER_LENGTH(expr) or OCTET_LENGTH(expr) string expression.
Fields
unit: StringLengthUnitWhether the length counts characters or UTF-8 bytes.
RegexpReplace
SQL REGEXP_REPLACE(expr, pattern, replacement) string expression.
Fields
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: UnaryMathOpFunction applied to each row.
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
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
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.
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.
Case
Searched SQL CASE WHEN ... THEN ... ELSE ... END.
Fields
Extract
SQL date/time field extraction.
Fields
DateTrunc
SQL DATE_TRUNC(field, expr) expression.
Fields
Alias
Output alias for projection and aggregate argument naming.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn children(&self) -> impl Iterator<Item = &Expr>
pub fn children(&self) -> impl Iterator<Item = &Expr>
Direct child expressions in evaluation order.
Sourcepub fn any(&self, predicate: impl FnMut(&Expr) -> bool) -> bool
pub fn any(&self, predicate: impl FnMut(&Expr) -> bool) -> bool
Whether predicate holds for this expression or any expression below
it, visited depth first.
Sourcepub fn columns(&self) -> impl Iterator<Item = &ColumnRef>
pub fn columns(&self) -> impl Iterator<Item = &ColumnRef>
Every column this expression references, in depth-first order.
Sourcepub fn column(name: impl Into<String>) -> Self
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.
Sourcepub fn input_column(
input: usize,
name: impl Into<String>,
display_name: impl Into<String>,
) -> Self
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.
Sourcepub fn literal(value: LiteralValue) -> Self
pub fn literal(value: LiteralValue) -> Self
Typed literal; the Arrow type travels with the value.
Sourcepub fn binary(left: Self, op: BinaryOp, right: Self) -> Self
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.
Sourcepub fn binary_with_output_type(
left: Self,
op: BinaryOp,
right: Self,
output_type: DataType,
) -> Self
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.
Sourcepub fn logical_not(expr: Self) -> Self
pub fn logical_not(expr: Self) -> Self
SQL NOT; the Not operator impl builds the same node.
Sourcepub fn is_not_null(expr: Self) -> Self
pub fn is_not_null(expr: Self) -> Self
SQL IS NOT NULL; the result is never null.
Sourcepub fn cast(expr: Self, target_type: DataType) -> Self
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.
Sourcepub fn try_cast(expr: Self, target_type: DataType) -> Self
pub fn try_cast(expr: Self, target_type: DataType) -> Self
SQL TRY_CAST; native execution admits only Utf8 to integer targets.
Sourcepub fn like(expr: Self, pattern: impl Into<String>) -> Self
pub fn like(expr: Self, pattern: impl Into<String>) -> Self
SQL LIKE without an ESCAPE clause; % and _ are wildcards.
Sourcepub fn not_like(expr: Self, pattern: impl Into<String>) -> Self
pub fn not_like(expr: Self, pattern: impl Into<String>) -> Self
SQL NOT LIKE without an ESCAPE clause.
Sourcepub fn like_escape(
expr: Self,
pattern: impl Into<String>,
escape: impl Into<String>,
) -> Self
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.
Sourcepub fn not_like_escape(
expr: Self,
pattern: impl Into<String>,
escape: impl Into<String>,
) -> Self
pub fn not_like_escape( expr: Self, pattern: impl Into<String>, escape: impl Into<String>, ) -> Self
SQL NOT LIKE ... ESCAPE escape.
Sourcepub fn substring(expr: Self, start: i32, length: Option<i32>) -> Self
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.
Sourcepub fn trim(expr: Self, trim_chars: impl Into<String>) -> Self
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.
Sourcepub fn ltrim(expr: Self, trim_chars: impl Into<String>) -> Self
pub fn ltrim(expr: Self, trim_chars: impl Into<String>) -> Self
Leading-only trim; see Self::Trim.
Sourcepub fn rtrim(expr: Self, trim_chars: impl Into<String>) -> Self
pub fn rtrim(expr: Self, trim_chars: impl Into<String>) -> Self
Trailing-only trim; see Self::Trim.
Sourcepub fn string_contains(expr: Self, pattern: impl Into<String>) -> Self
pub fn string_contains(expr: Self, pattern: impl Into<String>) -> Self
Boolean test that expr contains the literal pattern; no wildcard
interpretation.
Sourcepub fn starts_with(expr: Self, prefix: impl Into<String>) -> Self
pub fn starts_with(expr: Self, prefix: impl Into<String>) -> Self
Boolean test that expr starts with the literal prefix.
Sourcepub fn ends_with(expr: Self, suffix: impl Into<String>) -> Self
pub fn ends_with(expr: Self, suffix: impl Into<String>) -> Self
Boolean test that expr ends with the literal suffix.
Sourcepub fn string_length(expr: Self, output_type: DataType) -> Self
pub fn string_length(expr: Self, output_type: DataType) -> Self
SQL CHARACTER_LENGTH with the frontend-declared output_type.
Sourcepub fn octet_length(expr: Self, output_type: DataType) -> Self
pub fn octet_length(expr: Self, output_type: DataType) -> Self
SQL OCTET_LENGTH with the frontend-declared output_type.
Sourcepub fn regexp_replace(
expr: Self,
pattern: impl Into<String>,
replacement: impl Into<String>,
output_type: DataType,
) -> Self
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.
Sourcepub fn concat(exprs: Vec<Self>) -> Self
pub fn concat(exprs: Vec<Self>) -> Self
SQL CONCAT; null inputs contribute empty strings, as in DataFusion.
Sourcepub fn unary_math(op: UnaryMathOp, expr: Self, output_type: DataType) -> Self
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.
Sourcepub fn round(expr: Self, decimal_places: i32, output_type: DataType) -> Self
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.
Sourcepub fn in_list(expr: Self, list: Vec<Self>) -> Self
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.
Sourcepub fn not_in_list(expr: Self, list: Vec<Self>) -> Self
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.
Sourcepub fn is_distinct_from(left: Self, right: Self) -> Self
pub fn is_distinct_from(left: Self, right: Self) -> Self
Null-aware inequality; the result is never null.
Sourcepub fn is_not_distinct_from(left: Self, right: Self) -> Self
pub fn is_not_distinct_from(left: Self, right: Self) -> Self
Null-aware equality; the result is never null.
Sourcepub fn case(branches: Vec<CaseWhen>, else_expr: Self) -> Self
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.
Sourcepub fn extract(field: DatePart, expr: Self) -> Self
pub fn extract(field: DatePart, expr: Self) -> Self
SQL EXTRACT(field FROM expr); native execution supports the fields in
DatePart::EXTRACT_FIELDS.
Sourcepub fn date_trunc(field: DatePart, expr: Self, output_type: DataType) -> Self
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.
Sourcepub fn alias(self, alias: impl Into<String>) -> Self
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.
Sourcepub fn contains_regexp_replace(&self) -> bool
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.