raminqaf commented on PR #27793:
URL: https://github.com/apache/flink/pull/27793#issuecomment-7306228808

   > it still returns wrong results sometimes e.g.
   > 
   > SELECT TO_TIMESTAMP('2023-01-01 12:30:00.12348', 'yyyy-MM-dd 
HH:mm:ss.SSSS');
   > returns
   > 
   > ```
   > 2023-01-01 12:30:00.1234
   > ```
   > 
   > while other vendors return
   > 
   > ```
   > 2023-01-01 12:30:00.1235
   > ```
   > 
   > e.g. https://onecompiler.com/postgresql/45aqrcapz
   > 
   > also we can play with other mask to uncover other cases
   
   Thanks, good find. Flink truncates the extra digits, while PostgreSQL rounds 
them. I kept truncation because Flink's CAST also truncates: `CAST('2023-01-01 
12:30:00.12348' AS TIMESTAMP(4))` returns `.1234`. Engines differ here. Spark 
and DuckDB reject the input.
   
   Checking this showed a worse problem. The format asks for 4 digits (`SSSS`) 
and the input has 5, so the parse fell back to a parser that ignores the 
format. That parser kept all 5 digits in a `TIMESTAMP(4`) value. It printed as 
`.1234`, but comparing it with `TIMESTAMP '2023-01-01 12:30:00.1234'` returned 
false. The first commit now truncates in that fallback too. `TO_TIMESTAMP_LTZ` 
has the same problem since 2.3.0, filed as 
[FLINK-41740](https://issues.apache.org/jira/browse/FLINK-41740).


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