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
impl Predicate
Sourcepub fn references(&self) -> HashSet<&ColumnName>
pub fn references(&self) -> HashSet<&ColumnName>
Returns a set of columns referenced by this predicate.
Sourcepub fn column<A>(field_names: impl IntoIterator<Item = A>) -> Predicatewhere
ColumnName: FromIterator<A>,
pub fn column<A>(field_names: impl IntoIterator<Item = A>) -> Predicatewhere
ColumnName: FromIterator<A>,
Creates a new boolean column reference. See also Expression::column.
Sourcepub const fn null_literal() -> Self
pub const fn null_literal() -> Self
Creates a NULL literal boolean value
Sourcepub fn from_expr(expr: impl Into<Expression>) -> Self
pub fn from_expr(expr: impl Into<Expression>) -> Self
Converts a boolean-valued expression into a predicate
Sourcepub fn is_null(expr: impl Into<Expression>) -> Predicate
pub fn is_null(expr: impl Into<Expression>) -> Predicate
Create a new predicate self IS NULL
Sourcepub fn is_not_null(expr: impl Into<Expression>) -> Predicate
pub fn is_not_null(expr: impl Into<Expression>) -> Predicate
Create a new predicate self IS NOT NULL
Sourcepub fn eq(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn eq(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self == other
Sourcepub fn ne(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn ne(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self != other
Sourcepub fn le(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn le(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self <= other
Sourcepub fn lt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn lt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self < other
Sourcepub fn ge(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn ge(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self >= other
Sourcepub fn gt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn gt(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate self > other
Sourcepub fn distinct(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
pub fn distinct(a: impl Into<Expression>, b: impl Into<Expression>) -> Self
Create a new predicate DISTINCT(self, other)
Sourcepub fn and(a: impl Into<Self>, b: impl Into<Self>) -> Self
pub fn and(a: impl Into<Self>, b: impl Into<Self>) -> Self
Create a new predicate self AND other
Sourcepub fn and_from(preds: impl IntoIterator<Item = Self>) -> Self
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.
Sourcepub fn or_from(preds: impl IntoIterator<Item = Self>) -> Self
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.
Sourcepub fn unary(op: UnaryPredicateOp, expr: impl Into<Expression>) -> Self
pub fn unary(op: UnaryPredicateOp, expr: impl Into<Expression>) -> Self
Creates a new unary predicate OP expr
Sourcepub fn binary(
op: BinaryPredicateOp,
lhs: impl Into<Expression>,
rhs: impl Into<Expression>,
) -> Self
pub fn binary( op: BinaryPredicateOp, lhs: impl Into<Expression>, rhs: impl Into<Expression>, ) -> Self
Creates a new binary predicate lhs OP rhs
Sourcepub fn junction(
op: JunctionPredicateOp,
preds: impl IntoIterator<Item = Self>,
) -> Self
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, becausetrue AND p==pfor any predicatep.OR()->false, becausefalse OR p==pfor any predicatep.
- Single-element junction unwraps the element:
AND(p)/OR(p)->p.
Sourcepub fn opaque(
op: impl OpaquePredicateOp,
exprs: impl IntoIterator<Item = Expression>,
) -> Self
pub fn opaque( op: impl OpaquePredicateOp, exprs: impl IntoIterator<Item = Expression>, ) -> Self
Creates a new opaque 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.
impl ArrowOpaquePredicate for Predicate
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
fn arrow_opaque<T: ArrowOpaquePredicateOp>( op: T, exprs: impl IntoIterator<Item = Expression>, ) -> Predicate
Predicate::opaque.Source§impl<'de> Deserialize<'de> for Predicate
impl<'de> Deserialize<'de> for Predicate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<ColumnName> for Predicate
impl From<ColumnName> for Predicate
Source§fn from(value: ColumnName) -> Self
fn from(value: ColumnName) -> Self
Source§impl From<Predicate> for Expression
impl From<Predicate> for Expression
impl StructuralPartialEq for Predicate
Auto Trait Implementations§
impl Freeze for Predicate
impl !RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl !UnwindSafe for Predicate
Blanket Implementations§
Source§impl<T> AsAny for T
impl<T> AsAny for T
Source§fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
dyn Any reference to the object: Read moreSource§fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ
fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ
Arc<dyn Any> reference to the object: Read moreSource§fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn Any>: Read moreSource§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynPartialEq for T
impl<T> DynPartialEq for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.
Source§impl<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
impl<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
Source§fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
default-engine-native-tls or default-engine-rustls or arrow-conversion) and crate feature arrow-conversion only.Source§impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
Source§fn try_into_kernel(self) -> Result<KernelType, ArrowError>
fn try_into_kernel(self) -> Result<KernelType, ArrowError>
default-engine-native-tls or default-engine-rustls or arrow-conversion) and crate feature arrow-conversion only.