pub fn try_eval_constant_expr(expr: &Expression) -> Option<Value>Expand description
Evaluate a column-free AST expression to a concrete Value at query time.
Returns Some(value) if the expression is entirely self-contained (no column
references) and can be evaluated. Returns None if the expression references
columns, contains context-dependent functions, or evaluation fails.
This is used by pushdown rules to resolve compound constant expressions like
NOW() - INTERVAL '24 hours' into concrete Values for index/storage filtering.
Non-deterministic functions like NOW() and RANDOM() ARE allowed here — they produce valid values with a blank context (they read system clock / RNG). Only context-dependent functions (CURRENT_TRANSACTION_ID) are rejected because they require ExecuteContext fields that are unavailable here.
Note: this is distinct from compile-time constant folding (which rejects ALL non-deterministic functions to avoid caching stale values in the program LRU).