Skip to main content

is_pure

Function is_pure 

Source
pub fn is_pure(expr: &ExprImpl) -> bool
Expand description

Returns whether every function in the expression always produces the same result for the same inputs, so that the expression can be re-evaluated or moved by the optimizer.

  • Built-in scalar and table functions are pure when they are deterministic, as classified by ImpureAnalyzer. NOW, PROCTIME and secret references are impure.
  • User-defined scalar functions are pure when they are declared IMMUTABLE. The planner trusts the declaration; it cannot verify the implementation. User-defined table functions are always impure.

A pure expression may still have its evaluated results materialized on retract streams: a UDF keeps materialization unless it sets unsafe_skip_materializing_exprs. Whether an expression needs materialization is decided by needs_materialization.