waitingkuo opened a new issue, #4106:
URL: https://github.com/apache/arrow-datafusion/issues/4106

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   A clear and concise description of what the problem is. Ex. I'm always 
frustrated when [...] 
   (This section helps Arrow developers understand the context and *why* for 
this feature, in addition to  the *what*)
   
   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**
   A clear and concise description of what you want to happen.
   
   1. enable `SET TIME TO [SOME_TIMEZONE]`
   It's currently disabled on purpose
   
   
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/sql/src/planner.rs#L2484-L2489
   
   i'd like to remove it (probably replaced by some tz verification) and have 
this as the result
   ```bash
   ❯ 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.
   ```
   
   
   2. `now()` returns the `Timestamp<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
   ```bash
   ❯ 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
   ```bash
   ❯ 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.
   ```
   
   3. `TimestampTz` should use the timezone from `config_options`
   
   
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/sql/src/planner.rs#L2832-L2841
   
   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`
   
   
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/sql/src/planner.rs#L2811-L2817
   
   3-2. Add `get_config_option` in `ContextProvider` so that we could get the 
time zone
   
   
https://github.com/apache/arrow-datafusion/blob/7e944ede86457fe0f43be44e0e5550229ecaf008/datafusion/sql/src/planner.rs#L2832-L2841
   
   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.
   


-- 
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]

Reply via email to