r33s3n6 opened a new issue, #68724:
URL: https://github.com/apache/doris/issues/68724

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   ### Version
   
   4.1.4 (doris-4.1.4-rc04-ad35a140c7f), single FE + single BE
   
   ### What's Wrong?
   
   `convert_tz('2024-01-01 00:00:00', '+08:00:00', 'UTC')` folds to 2023-12-31 
16:00:00 in FE; with the arguments in columns BE fails with `invalid timezone: 
+08:00:00`.
   
   FE folding: `2023-12-31 16:00:00`. BE: error `invalid timezone: +08:00:00`.
   
   ```
   SET enable_sql_cache = false
   
   SELECT convert_tz('2024-01-01 00:00:00', '+08:00:00', 'UTC') AS fe FROM t
   
   +---------------------+
   | fe                  |
   +---------------------+
   | 2023-12-31 16:00:00 |
   +---------------------+
   
   SELECT convert_tz(dtm1, s1, 'UTC') AS be FROM t
   
   ERROR 1105 (HY000) at line 3: errCode = 2, detailMessage = 
(10.30.42.3)[INVALID_ARGUMENT]Operation convert_tz invalid timezone: +08:00:00
   
   SET debug_skip_fold_constant = true
   
   SELECT convert_tz('2024-01-01 00:00:00', '+08:00:00', 'UTC')
   
   ERROR 1105 (HY000) at line 5: errCode = 2, detailMessage = 
(10.30.42.3)[INVALID_ARGUMENT][E33] Operation convert_tz invalid timezone: 
+08:00:00
   ```
   
   - **FE constant folding**: all arguments are literals, so Nereids folds the 
call during planning. Check: EXPLAIN shows the literal in place of the call: 
`final projections: '2023-12-31 16:00:00'`
   - **BE execution**: the arguments are columns (or `SET 
debug_skip_fold_constant = true`), so BE computes the call. Check: EXPLAIN 
keeps the call.
   
   ### What You Expected?
   
   FE and BE accept the same time zone strings.
   
   ### How to Reproduce?
   
   Deployment: single FE + single BE, default session variables.
   
   ```sql
   CREATE TABLE t(id INT, s1 STRING, dtm1 DATETIME)
     DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');
   INSERT INTO t VALUES (1, '+08:00:00', '2024-01-01 00:00:00');
   
   SET enable_sql_cache = false;
   SELECT convert_tz('2024-01-01 00:00:00', '+08:00:00', 'UTC') AS fe FROM t;
   SELECT convert_tz(dtm1, s1, 'UTC') AS be FROM t;
   SET debug_skip_fold_constant = true;
   SELECT convert_tz('2024-01-01 00:00:00', '+08:00:00', 'UTC');
   ```
   
   ### Anything Else?
   
   FE validates only `±HH:MM` offsets and parses everything else with 
`java.time` (`appendZoneOrOffsetId`), which accepts `+08:00:00`; BE looks the 
name up with `TimezoneUtils::find_cctz_time_zone`, which does not.
   
   - FE: 
[fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java#L805-L817](https://github.com/apache/doris/blob/4.1.4/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java#L805-L817)
 — `convertTz`: `appendZoneOrOffsetId`
   - BE: 
[be/src/exprs/function/function_convert_tz.cpp#L126-L129](https://github.com/apache/doris/blob/4.1.4/be/src/exprs/function/function_convert_tz.cpp#L126-L129)
 — `find_cctz_time_zone` fails
   
   Found with AI assistance.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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

Reply via email to