pub enum Predicate {
Show 21 variants
Eq(ColumnName, PredicateValue),
Lt(ColumnName, PredicateValue),
Le(ColumnName, PredicateValue),
Gt(ColumnName, PredicateValue),
Ge(ColumnName, PredicateValue),
In(ColumnName, Vec<PredicateValue>),
NotIn(ColumnName, Vec<PredicateValue>),
NotBetween(ColumnName, PredicateValue, PredicateValue),
Like(ColumnName, String),
NotLike(ColumnName, String),
ILike(ColumnName, String),
NotILike(ColumnName, String),
IsNull(ColumnName),
IsNotNull(ColumnName),
JsonExtractEq {
column: ColumnName,
path: String,
as_text: bool,
value: PredicateValue,
},
JsonContains {
column: ColumnName,
value: PredicateValue,
},
InSubquery {
column: ColumnName,
subquery: Box<ParsedSelect>,
negated: bool,
},
Exists {
subquery: Box<ParsedSelect>,
negated: bool,
},
Always(bool),
Or(Vec<Predicate>, Vec<Predicate>),
ScalarCmp {
lhs: ScalarExpr,
op: ScalarCmpOp,
rhs: ScalarExpr,
},
}Expand description
A comparison predicate from the WHERE clause.
Variants§
Eq(ColumnName, PredicateValue)
column = value or column = $N
Lt(ColumnName, PredicateValue)
column < value
Le(ColumnName, PredicateValue)
column <= value
Gt(ColumnName, PredicateValue)
column > value
Ge(ColumnName, PredicateValue)
column >= value
In(ColumnName, Vec<PredicateValue>)
column IN (value, value, …)
NotIn(ColumnName, Vec<PredicateValue>)
column NOT IN (value, value, …)
NotBetween(ColumnName, PredicateValue, PredicateValue)
column NOT BETWEEN low AND high
Like(ColumnName, String)
column LIKE ‘pattern’
NotLike(ColumnName, String)
column NOT LIKE ‘pattern’
ILike(ColumnName, String)
column ILIKE ‘pattern’ (case-insensitive LIKE)
NotILike(ColumnName, String)
column NOT ILIKE ‘pattern’
IsNull(ColumnName)
column IS NULL
IsNotNull(ColumnName)
column IS NOT NULL
JsonExtractEq
JSON path extraction with comparison.
data->'key' = value → as_text=false (compare as JSON value)
data->>'key' = value → as_text=true (compare as text)
Fields
column: ColumnNameThe JSON column being extracted from.
value: PredicateValueValue to compare extracted result against.
JsonContains
JSON containment: column @> value — column (a JSON value) contains value.
InSubquery
column IN (SELECT ...) / column NOT IN (SELECT ...).
- Uncorrelated form: pre-executed in
pre_execute_subqueriesand rewritten toPredicate::In/Predicate::NotInbefore planning. - Correlated form: detected in the same pass, left in place, and handled by the correlated-loop executor (v0.6.0).
See docs/reference/sql/correlated-subqueries.md.
Exists
EXISTS (SELECT ...) and NOT EXISTS (...).
- Uncorrelated form: pre-executed and rewritten to
Always(bool). - Correlated form: left in place for the correlated-loop executor.
Always(bool)
Constant truth value: matches every row (true) or no rows (false).
Produced by the subquery pre-execution pass: an EXISTS whose inner
query returns rows becomes Always(true), an empty EXISTS becomes
Always(false). Decoupling these from regular column predicates means
the rest of the planner doesn’t need to invent sentinel columns.
Or(Vec<Predicate>, Vec<Predicate>)
OR of multiple predicates
ScalarCmp
Comparison between two arbitrary scalar expressions.
Used for any WHERE predicate where one or both sides is a
function call, CAST, or || operator — e.g.
UPPER(name) = 'ALICE', COALESCE(x, 0) > 10,
CAST(s AS INTEGER) = $1. The bare column/literal predicates
above stay on the hot path; this variant is the fallback when
the bare shape doesn’t match.