-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is your feature request related to a problem or challenge?
I'm doing some rewrites where I want to handle now(), but if I run the query through the optimizer if evaluates it using the current time.
Describe the solution you'd like
I'd like to add a configuration to OptimzierConfig to disable these evaluations: evaluate_stable_functions = false;
Describe alternatives you've considered
Wrapping every stable function in a UDF that is pass through but modifies the signature to Immutable. This is complex and error prone (there's like a dozen methods in the UDF trait).
Motivation
I am working on a feature to cache / materialize scan subtrees of queries. I am essentially transforming a query like:
select time_bucket('1 minute', ts)
from t
where ts > now() - interval '1 hour';Into a materializable subtree:
select time_bucket('1 minute', ts) as __0, ts
from t;And a query to apply on top of that:
select __0 as "time_bucket('1 minute', ts)"
from __mv
where ts > now() - interval '1 hour';As part of this I want to be able to pass the SQL text / string through optimizers to generally normalize / optimize the query, but this currently evaluates now(), which would result in materializing:
select time_bucket('1 minute', ts) as __0, ts
from t
where ts > '2025-...';Because I have no way of differentiating a literal date from an evaluated now().