adriangb commented on issue #19470: URL: https://github.com/apache/datafusion/issues/19470#issuecomment-3693589798
It occurred to me that one option is to evaluate these functions during logical -> physical planning. Essentially we traverse the logical plan looking for all expressions (there is infrastructure to make this easy) and for every function that is: 1) Stable 2) Has no inputs We store a `HashMap<&str, Arc<Literal>>` (or some other way to reference the function). The first time we encounter a function we evaluate it (we'll have to implement `NowFunc::invoke_with_args` to call `Utc::now()`) and get out the literal value. Subsequent encounters with that function would be planned by cloning the `Literal` instead of evaluating the function again. So essentially DataFusion handles the "immutability" of this function for users, users just have to implement the function as normal. If there are stable functions with arguments (currently none exist that I know of) we would error during planning. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
