Skip to main content

Predicate

Enum Predicate 

Source
pub enum Predicate {
    BooleanExpression(Expression),
    Not(Box<Predicate>),
    Unary(UnaryPredicate),
    Binary(BinaryPredicate),
    Junction(JunctionPredicate),
    Opaque(OpaquePredicate),
    Unknown(String),
}
Expand description

A SQL predicate.

These predicates do not track or validate data types, other than the type of literals. It is up to the predicate evaluator to validate the predicate against a schema and add appropriate casts as required.

Variants§

§

BooleanExpression(Expression)

A boolean-valued expression, useful for e.g. AND(<boolean_col1>, <boolean_col2>).

§

Not(Box<Predicate>)

Boolean inversion (true <-> false)

NOTE: NOT is not a normal unary predicate, because it requires a predicate as input (not an expression), and is never directly evaluated. Instead, observing that all predicates are invertible, NOT is always pushed down into its child predicate, inverting it. For example, NOT (a < b) pushes down and inverts < to >=, producing a >= b.

§

Unary(UnaryPredicate)

A unary operation.

§

Binary(BinaryPredicate)

A binary operation.

§

Junction(JunctionPredicate)

A junction operation (AND/OR).

§

Opaque(OpaquePredicate)

A predicate that the engine defines and implements. Kernel interacts with the predicate only through methods provided by the OpaquePredicateOp trait.

§

Unknown(String)

An unknown predicate (i.e. one that neither kernel nor engine attempts to evaluate). For data skipping purposes, kernel treats unknown predicates as if they were literal NULL values (which may disable skipping if it “poisons” the predicate), but engines MUST NOT attempt to interpret them as NULL when evaluating query filters because it could produce incorrect results. For example, converting WHERE <fancy-udf-invocation> to WHERE NULL is equivalent to WHERE FALSE and would filter out all rows – almost certainly NOT what the query author intended. Use Predicate::Opaque for predicates kernel doesn’t understand but which engine can still evaluate.

Implementations§

Source§

impl Predicate

Source

pub fn references(&self) -> HashSet<&ColumnName>

Returns a set of columns referenced by this predicate.

Source

pub fn column<A>(field_names: impl IntoIterator<Item = A>) -> Predicate

Creates a new boolean column reference. See also Expression::column.

Source

pub const fn literal(value: bool) -> Self

Create a new literal boolean value

Source

pub const fn null_literal() -> Self

Creates a NULL literal boolean value

Source

pub fn from_expr(expr: impl Into<Expression>) -> Self

Converts a boolean-valued expression into a predicate

Source

pub fn not(pred: impl Into<Self>) -> Self

Logical NOT (boolean inversion)

Source

pub fn is_null(expr: impl Into<Expression>) -> Predicate

Create a new predicate self IS NULL

Source

pub fn is_not_null(expr: impl Into<Expression>) -> Predicate

Create a new predicate self IS NOT NULL

Source

pub fn eq(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self == other

Source

pub fn ne(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self != other

Source

pub fn le(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self <= other

Source

pub fn lt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self < other

Source

pub fn ge(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self >= other

Source

pub fn gt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate self > other

Source

pub fn distinct(a: impl Into<Expression>, b: impl Into<Expression>) -> Self

Create a new predicate DISTINCT(self, other)

Source

pub fn and(a: impl Into<Self>, b: impl Into<Self>) -> Self

Create a new predicate self AND other

Source

pub fn or(a: impl Into<Self>, b: impl Into<Self>) -> Self

Create a new predicate self OR other

Source

pub fn and_from(preds: impl IntoIterator<Item = Self>) -> Self

Creates a new predicate AND(preds…). See Self::junction for normalization of empty and single-element inputs.

Source

pub fn or_from(preds: impl IntoIterator<Item = Self>) -> Self

Creates a new predicate OR(preds…). See Self::junction for normalization of empty and single-element inputs.

Source

pub fn unary(op: UnaryPredicateOp, expr: impl Into<Expression>) -> Self

Creates a new unary predicate OP expr

Source

pub fn binary( op: BinaryPredicateOp, lhs: impl Into<Expression>, rhs: impl Into<Expression>, ) -> Self

Creates a new binary predicate lhs OP rhs

Source

pub fn junction( op: JunctionPredicateOp, preds: impl IntoIterator<Item = Self>, ) -> Self

Creates a new junction predicate OP(preds…). Normalizes degenerate cases:

  • Empty junction returns the identity element (the value that has no effect when combined with other predicates under the same operator):
    • AND() -> true, because true AND p == p for any predicate p.
    • OR() -> false, because false OR p == p for any predicate p.
  • Single-element junction unwraps the element: AND(p) / OR(p) -> p.
Source

pub fn opaque( op: impl OpaquePredicateOp, exprs: impl IntoIterator<Item = Expression>, ) -> Self

Creates a new opaque predicate

Source

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

Creates a new unknown predicate

Trait Implementations§

Source§

impl ArrowOpaquePredicate for Predicate

Available on crate feature arrow-expression and crate feature default-engine-base and (crate features default-engine-native-tls or default-engine-rustls or arrow-conversion) only.
Source§

fn arrow_opaque<T: ArrowOpaquePredicateOp>( op: T, exprs: impl IntoIterator<Item = Expression>, ) -> Predicate

Creates a new opaque predicate. See also Predicate::opaque.
Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

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 Predicate

Source§

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

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

impl<'de> Deserialize<'de> for Predicate

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Predicate

Source§

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

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

impl From<ColumnName> for Predicate

Source§

fn from(value: ColumnName) -> Self

Converts to this type from the input type.
Source§

impl From<Predicate> for Expression

Source§

fn from(value: Predicate) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Predicate

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Predicate

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Predicate

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> AsAny for T
where T: Any + Send + Sync,

Source§

fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)

Obtains a dyn Any reference to the object: Read more
Source§

fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Obtains an Arc<dyn Any> reference to the object: Read more
Source§

fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts the object to Box<dyn Any>: Read more
Source§

fn type_name(&self) -> &'static str

Convenient wrapper for std::any::type_name, since Any does not provide it and Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).
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> DynPartialEq for T
where T: PartialEq + AsAny,

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelType
where ArrowType: TryFromKernel<KernelType>,

Source§

fn try_into_arrow(self) -> Result<ArrowType, ArrowError>

Available on (crate features default-engine-native-tls or default-engine-rustls or arrow-conversion) and crate feature arrow-conversion only.
Source§

impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowType
where KernelType: TryFromArrow<ArrowType>,

Source§

fn try_into_kernel(self) -> Result<KernelType, ArrowError>

Available on (crate features default-engine-native-tls or default-engine-rustls or arrow-conversion) and crate feature arrow-conversion only.
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,