You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "xonx4l (via GitHub)" <gi...@apache.org> on 2026/02/08 13:19:21 UTC

Re: [PR] Refactor(optimizer): Simplify Stable ScalarUDFs using physical execution [datafusion]

xonx4l commented on code in PR #19675:
URL: https://github.com/apache/datafusion/pull/19675#discussion_r2779257907


##########
datafusion/functions/src/datetime/now.rs:
##########
@@ -112,26 +111,11 @@ impl ScalarUDFImpl for NowFunc {
         internal_err!("return_field_from_args should be called instead")
     }
 
-    fn invoke_with_args(
-        &self,
-        _args: datafusion_expr::ScalarFunctionArgs,
-    ) -> Result<ColumnarValue> {
-        internal_err!("invoke should not be called on a simplified now() function")
-    }
-
-    fn simplify(
-        &self,
-        _args: Vec<Expr>,
-        info: &dyn SimplifyInfo,
-    ) -> Result<ExprSimplifyResult> {
-        let now_ts = info
-            .execution_props()
-            .query_execution_start_time
-            .timestamp_nanos_opt();
-
-        Ok(ExprSimplifyResult::Simplified(Expr::Literal(
-            ScalarValue::TimestampNanosecond(now_ts, self.timezone.clone()),
-            None,
+    fn invoke_with_args(&self, _args: ScalarFunctionArgs) -> Result<ColumnarValue> {
+        let now = chrono::Utc::now();

Review Comment:
   Oh yeah that's makes sense . I think modifying the helper to try udf.simplify() will be the right approach to go forward what you think if that make's sense ? In order to follow I will first  restore the custom simplify implementation.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org