pub struct LiteralGuarantee {
pub column: Column,
pub guarantee: Guarantee,
pub literals: HashSet<ScalarValue>,
}
Expand description
Represents a guarantee that must be true for a boolean expression to
evaluate to true
.
The guarantee takes the form of a column and a set of literal (constant)
ScalarValue
s. For the expression to evaluate to true
, the column must
satisfy the guarantee(s).
To satisfy the guarantee, depending on Guarantee
, the values in the
column must either:
- be ONLY one of that set
- NOT be ANY of that set
§Uses LiteralGuarantee
s
LiteralGuarantee
s can be used to simplify filter expressions and skip data
files (e.g. row groups in parquet files) by proving expressions can not
possibly evaluate to true
. For example, if we have a guarantee that a
must be in (1
) for a filter to evaluate to true
, then we can skip any
partition where we know that a
never has the value of 1
.
Important: If a LiteralGuarantee
is not satisfied, the relevant
expression is guaranteed to evaluate to false
or null
. However,
the opposite does not hold. Even if all LiteralGuarantee
s are satisfied,
that does not guarantee that the predicate will actually evaluate to
true
: it may still evaluate to true
, false
or null
.
§Creating LiteralGuarantee
s
Use LiteralGuarantee::analyze
to extract literal guarantees from a
filter predicate.
§Details
A guarantee can be one of two forms:
-
The column must be one the values for the predicate to be
true
. If the column takes on any other value, the predicate can not evaluate totrue
. For example,(a = 1)
,(a = 1 OR a = 2)
ora IN (1, 2, 3)
-
The column must NOT be one of the values for the predicate to be
true
. If the column can ONLY take one of these values, the predicate can not evaluate totrue
. For example,(a != 1)
,(a != 1 AND a != 2)
ora NOT IN (1, 2, 3)
Fields§
§column: Column
§guarantee: Guarantee
§literals: HashSet<ScalarValue>
Implementations§
Source§impl LiteralGuarantee
impl LiteralGuarantee
Sourcepub fn analyze(expr: &Arc<dyn PhysicalExpr>) -> Vec<LiteralGuarantee>
pub fn analyze(expr: &Arc<dyn PhysicalExpr>) -> Vec<LiteralGuarantee>
Return a list of LiteralGuarantee
s that must be satisfied for expr
to evaluate to true
.
If more than one LiteralGuarantee
is returned, they must all hold
for the expression to possibly be true
. If any is not satisfied, the
expression is guaranteed to be null
or false
.
§Notes:
expr
must be a boolean expression or inlist expression.expr
is not simplified prior to analysis.
Trait Implementations§
Source§impl Clone for LiteralGuarantee
impl Clone for LiteralGuarantee
Source§fn clone(&self) -> LiteralGuarantee
fn clone(&self) -> LiteralGuarantee
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LiteralGuarantee
impl Debug for LiteralGuarantee
Source§impl Display for LiteralGuarantee
impl Display for LiteralGuarantee
Source§impl PartialEq for LiteralGuarantee
impl PartialEq for LiteralGuarantee
impl StructuralPartialEq for LiteralGuarantee
Auto Trait Implementations§
impl Freeze for LiteralGuarantee
impl !RefUnwindSafe for LiteralGuarantee
impl Send for LiteralGuarantee
impl Sync for LiteralGuarantee
impl Unpin for LiteralGuarantee
impl !UnwindSafe for LiteralGuarantee
Blanket Implementations§
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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 more