[ 
https://issues.apache.org/jira/browse/FLINK-40731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18117767#comment-18117767
 ] 

sepuri sai krishna commented on FLINK-40731:
--------------------------------------------

Fair point, I checked.

`TO_TIMESTAMP_LTZ` takes a timezone too, and it rejects an unknown one. As a
literal it fails validation:

```
TO_TIMESTAMP_LTZ('2024-01-01 12:00:00', 'yyyy-MM-dd HH:mm:ss', 
'america/new_york')
  -> Invalid timezone for parsing TIMESTAMP_LTZ: Unknown time-zone ID
```

and when the timezone comes from an expression rather than a literal it returns
NULL.

`table.local-time-zone` is validated as well, in
`TableConfigValidation.validateTimeZone`, which compares `TimeZone.getTimeZone`
against `ZoneId.of` with the comment "to avoid bugs". `CONVERT_TZ` is the only
one of the three that accepts anything and falls back to GMT.

On the PR you're right, I jumped ahead. I'll leave it until there's agreement
here. Could you assign the ticket if this looks worth fixing?

> CONVERT_TZ silently returns a wrong timestamp for a time zone it does not 
> recognize
> -----------------------------------------------------------------------------------
>
>                 Key: FLINK-40731
>                 URL: https://issues.apache.org/jira/browse/FLINK-40731
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Runtime
>    Affects Versions: 2.4.0
>            Reporter: sepuri sai krishna
>            Priority: Major
>              Labels: pull-request-available
>
> When {{CONVERT_TZ}} does not recognize a time zone it returns a 
> converted-looking
> timestamp that is wrong, with no error and nothing logged. Zone ids are case
> sensitive, so an ordinary typo is enough:
> {code:sql}
> CONVERT_TZ('2024-01-01 12:00:00', 'UTC', 'America/New_York')  -- 2024-01-01 
> 07:00:00
> CONVERT_TZ('2024-01-01 12:00:00', 'UTC', 'america/new_york')  -- 2024-01-01 
> 12:00:00
> {code}
> Other bad input is already reported as NULL:
> {code:sql}
> CONVERT_TZ('not a timestamp', 'UTC', 'America/New_York')  -- NULL
> {code}
> Reproduced on master. I have a fix and tests ready, could someone assign this 
> to
> me?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to