-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I'd like to add the support for SET TIMEZONE.
I'd like to have now() and TimestampTz use the timezone in config_options instead of the fixed UTC
Describe the solution you'd like
- enable
SET TIME TO [SOME_TIMEZONE]
It's currently disabled on purpose
i'd like to remove it (probably replaced by some tz verification) and have this as the result
❯ set time zone to '+08:00';
0 rows in set. Query took 0.000 seconds.
❯ show time zone;
+--------------------------------+---------+
| name | setting |
+--------------------------------+---------+
| datafusion.execution.time_zone | +08:00 |
+--------------------------------+---------+
1 row in set. Query took 0.007 seconds.now()returns theTimestamp<TimeUnit::Nanosecond, Some("SOME_TIMEZONE")according to the time zone we have. it's currently fixed as "UTC"
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/physical-expr/src/datetime_expressions.rs#L176-L186
Some("UTC".to_owned()) should be modified. we need to pass config_options or time zone into here this function
e.g.
current version
❯ set time zone to '+08:00';
0 rows in set. Query took 0.000 seconds.
❯ select arrow_typeof(now());
+------------------------------------+
| arrowtypeof(now()) |
+------------------------------------+
| Timestamp(Nanosecond, Some("UTC")) |
+------------------------------------+
1 row in set. Query took 0.003 seconds.becomes
❯ set time zone to '+08:00';
0 rows in set. Query took 0.000 seconds.
❯ select arrow_typeof(now());
+---------------------------------------+
| arrowtypeof(now()) |
+---------------------------------------+
| Timestamp(Nanosecond, Some("+08:00")) |
+---------------------------------------+
1 row in set. Query took 0.003 seconds.TimestampTzshould use the timezone fromconfig_options
we currently fixed TimestampTz as "UTC" without considering config_options's timezone.
to enable it to consider config_options, we need to
3-1. make convert_simple_data_type as a method of SqlToRel
3-2. Add get_config_option in ContextProvider so that we could get the time zone
3-3 then we can use the timezone in config_options here to replace fixed UTC
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/sql/src/planner.rs#L2832-L2841
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.