Skip to main content

Predicate

Enum Predicate 

Source
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' = valueas_text=false (compare as JSON value) data->>'key' = valueas_text=true (compare as text)

Fields

§column: ColumnName

The JSON column being extracted from.

§path: String

The key path (single-level for now).

§as_text: bool

true for ->> (text result), false for -> (JSON result).

§value: PredicateValue

Value to compare extracted result against.

§

JsonContains

JSON containment: column @> valuecolumn (a JSON value) contains value.

Fields

§column: ColumnName
§

InSubquery

column IN (SELECT ...) / column NOT IN (SELECT ...).

  • Uncorrelated form: pre-executed in pre_execute_subqueries and rewritten to Predicate::In / Predicate::NotIn before 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.

Fields

§column: ColumnName
§subquery: Box<ParsedSelect>
§negated: bool

true for NOT IN (SELECT ...).

§

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.

Fields

§subquery: Box<ParsedSelect>
§negated: bool
§

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.

Implementations§

Source§

impl Predicate

Source

pub fn column(&self) -> Option<&ColumnName>

Returns the column name this predicate operates on.

Returns None for OR predicates which may reference multiple columns.

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

Returns a duplicate 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 Predicate

Source§

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

Formats the value using the given formatter. Read more

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, 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more