Struct datafusion_physical_expr::utils::LiteralGuarantee
source · 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) or
a 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
source§fn eq(&self, other: &LiteralGuarantee) -> bool
fn eq(&self, other: &LiteralGuarantee) -> bool
self
and other
values to be equal, and is used
by ==
.