pub trait StatsRewriteRule:
Debug
+ Send
+ Sync
+ 'static {
// Required method
fn scalar_fn_id(&self) -> ScalarFnId;
// Provided methods
fn falsify(
&self,
expr: &Expression,
ctx: &StatsRewriteCtx<'_>,
) -> VortexResult<Option<Expression>> { ... }
fn satisfy(
&self,
expr: &Expression,
ctx: &StatsRewriteCtx<'_>,
) -> VortexResult<Option<Expression>> { ... }
}Expand description
A plugin-provided rule for predicates whose root scalar function matches this rule.
Rules do not produce expressions equivalent to expr. They produce optional sufficient
conditions over stats for the current scope:
- a falsifier evaluating to
trueproves thatexpris false for every row in the scope; - a satisfier evaluating to
trueproves thatexpris true for every row in the scope.
Returning None means this rule cannot prove anything for the expression. A returned proof
expression that evaluates to false or null is also inconclusive.
Multiple rules may be registered for the same scalar function. Their proofs are combined with
OR, so every proof returned by an individual rule must be sound on its own.
expr is the full predicate expression whose root scalar function id is
Self::scalar_fn_id. Use StatsRewriteCtx to resolve dtypes and recursively rewrite child
predicates.
Required Methods§
Sourcefn scalar_fn_id(&self) -> ScalarFnId
fn scalar_fn_id(&self) -> ScalarFnId
Returns the scalar function id handled by this rule.
Provided Methods§
Sourcefn falsify(
&self,
expr: &Expression,
ctx: &StatsRewriteCtx<'_>,
) -> VortexResult<Option<Expression>>
fn falsify( &self, expr: &Expression, ctx: &StatsRewriteCtx<'_>, ) -> VortexResult<Option<Expression>>
Returns a stats-backed proof that expr is false for the current scope.
If the returned expression evaluates to true against the scope’s stats, then expr is
guaranteed to be false for every row in that scope. A returned proof expression that
evaluates to false or null is inconclusive.
Returns Ok(None) when this rule cannot construct a sound falsity proof for expr.
Sourcefn satisfy(
&self,
expr: &Expression,
ctx: &StatsRewriteCtx<'_>,
) -> VortexResult<Option<Expression>>
fn satisfy( &self, expr: &Expression, ctx: &StatsRewriteCtx<'_>, ) -> VortexResult<Option<Expression>>
Returns a stats-backed proof that expr is true for the current scope.
If the returned expression evaluates to true against the scope’s stats, then expr is
guaranteed to be true for every row in that scope. A returned proof expression that
evaluates to false or null is inconclusive.
This is not the complement of Self::falsify; both methods are one-way proofs and may be
implemented independently.
Returns Ok(None) when this rule cannot construct a sound truth proof for expr.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".