You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
The now() function currently is hardcoded to use +00:00 timezone. Now that functions have access to the ConfigOptions now() can be updated to use the tz set in 'datafusion.execution.time_zone'
Describe the solution you'd like
now() returns a timestamp in the tz set via the 'datafusion.execution.time_zone' config option.
Note that currently I don't think this is quite possible because the return_field_from_args function has no access to ConfigOptions. Leaving it as it is results in queries such as
>SETTIME ZONE '+08:00';
0 row(s) fetched.
Elapsed 0.002 seconds.
>selectcount(1) result from (select now() as n) a where n ='2000-01-01'::date;
Arrow error: Invalid argument error: Invalid comparison operation: Timestamp(Nanosecond, Some("+08:00")) ==Timestamp(Nanosecond, Some("+00:00"))
I've been poking at this for a while and I don't see an easy way to make this work. Wiring ConfigOptions into the return_field_from_args function touches far, far too many things for it to be worth it.
My best thought for making this work is to clone the ScalarUDF whenever it's needed (here for example) to make the UDF stateful and then call a new function say initialize(config_options: Arc<ConfigOptions>) which would then provide the function with any required state it required.
Without something like the above functions like now that do not have a return type that is determined by the args provided but rather determined externally or via configuration just can't work properly.
After investigation, I agree with @Omega359 that wiring ConfigOptions into return_field_from_args would be a massive undertaking with questionable ROI.
However, I'd like us to reconsider whether this feature justifies the architectural complexity.
The Core Issue
The problem manifests in subqueries:
-- Works fineSELECT now() ='2000-01-01'::date;
-- Fails with schema mismatchSELECTcount(1) FROM (SELECT now() as n) a WHERE n ='2000-01-01'::date;
Root Cause
Subquery schemas are materialized at planning time via return_field_from_args(), which lacks access to ConfigOptions. However, the actual return type comes from simplify(), which does have config access. This creates a schema/data type mismatch that Arrow rightfully rejects.
The Key Question
I don't see many other built-in functions requiring config-dependent return types. If now() is largely an isolated case, a major architectural refactor may not be warranted.
Proposal
Before proceeding with the refactor, I suggest we:
Identify if other functions have similar config-dependent behavior
Evaluate the user impact - how frequently is this pattern encountered?
The other thought I had for this issue was to add a listener for config changes and re-register any udf's that have a new_with_config(config_options: Arc<ConfigOptions>) constructor.
It came up today on our sync call with @Omega359 that this change might make it hard for downstream crates when upgrading to a new version of DataFusion if they can't go back to the existing behavior.
Thus I think we should ensure there is some way (e.g. a configuration setting change) to get the same behavior of DataFusion 50
For example, maybe we could just document that setting the timezone to "None" will return the behavior to DataFusion 50
Activity
Omega359 commentedon Oct 9, 2025
Note that currently I don't think this is quite possible because the
return_field_from_argsfunction has no access toConfigOptions. Leaving it as it is results in queries such as[-]Make now() aware of execution timezone[/-][+]Make now aware of execution timezone[/+]Omega359 commentedon Oct 10, 2025
I've been poking at this for a while and I don't see an easy way to make this work. Wiring ConfigOptions into the return_field_from_args function touches far, far too many things for it to be worth it.
My best thought for making this work is to clone the ScalarUDF whenever it's needed (here for example) to make the UDF stateful and then call a new function say
initialize(config_options: Arc<ConfigOptions>)which would then provide the function with any required state it required.Without something like the above functions like now that do not have a return type that is determined by the args provided but rather determined externally or via configuration just can't work properly.
Weijun-H commentedon Oct 12, 2025
After investigation, I agree with @Omega359 that wiring
ConfigOptionsintoreturn_field_from_argswould be a massive undertaking with questionable ROI.However, I'd like us to reconsider whether this feature justifies the architectural complexity.
The Core Issue
The problem manifests in subqueries:
Root Cause
Subquery schemas are materialized at planning time via
return_field_from_args(), which lacks access toConfigOptions. However, the actual return type comes fromsimplify(), which does have config access. This creates a schema/data type mismatch that Arrow rightfully rejects.The Key Question
I don't see many other built-in functions requiring config-dependent return types. If
now()is largely an isolated case, a major architectural refactor may not be warranted.Proposal
Before proceeding with the refactor, I suggest we:
Waiting for others' feedback on whether this pattern is common enough to justify the architectural investment.
Omega359 commentedon Oct 13, 2025
The other issues I filed I suspect all would be blocked by this issue:
The other thought I had for this issue was to add a listener for config changes and re-register any udf's that have a
new_with_config(config_options: Arc<ConfigOptions>)constructor.alamb commentedon Oct 15, 2025
It came up today on our sync call with @Omega359 that this change might make it hard for downstream crates when upgrading to a new version of DataFusion if they can't go back to the existing behavior.
Thus I think we should ensure there is some way (e.g. a configuration setting change) to get the same behavior of DataFusion 50
For example, maybe we could just document that setting the timezone to "None" will return the behavior to DataFusion 50
Update: this is what @Omega359 suggests here: #18017 (comment)
alamb commentedon Oct 15, 2025
Update: @Weijun-H has a PR up for this feature:
[-]Make now aware of execution timezone[/-][+]Make `now` aware of execution timezone[/+]fix: Use dynamic timezone in now() function for accurate timestamp (#…
fix: Use dynamic timezone in now() function for accurate timestamp (a…
fix: Use dynamic timezone in now() function for accurate timestamp (a…