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) ScalarValues. 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:

  1. be ONLY one of that set
  2. NOT be ANY of that set

§Uses LiteralGuarantees

LiteralGuarantees 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 LiteralGuarantees are satisfied, that does not guarantee that the predicate will actually evaluate to true: it may still evaluate to true, false or null.

§Creating LiteralGuarantees

Use LiteralGuarantee::analyze to extract literal guarantees from a filter predicate.

§Details

A guarantee can be one of two forms:

  1. 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 to true. For example, (a = 1), (a = 1 OR a = 2) or a IN (1, 2, 3)`

  2. 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 to true. For example, (a != 1), (a != 1 AND a != 2) or a NOT IN (1, 2, 3)

Fields§

§column: Column§guarantee: Guarantee§literals: HashSet<ScalarValue>

Implementations§

source§

impl LiteralGuarantee

source

pub fn analyze(expr: &Arc<dyn PhysicalExpr>) -> Vec<LiteralGuarantee>

Return a list of LiteralGuarantees 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:
  1. expr must be a boolean expression or inlist expression.
  2. expr is not simplified prior to analysis.

Trait Implementations§

source§

impl Clone for LiteralGuarantee

source§

fn clone(&self) -> LiteralGuarantee

Returns a copy 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 LiteralGuarantee

source§

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

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

impl Display for LiteralGuarantee

source§

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

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

impl PartialEq for LiteralGuarantee

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for LiteralGuarantee

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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