leonardBang commented on code in PR #22170:
URL: https://github.com/apache/flink/pull/22170#discussion_r1136511081


##########
docs/data/sql_functions.yml:
##########
@@ -499,7 +499,24 @@ temporal:
     description: Gets current Unix timestamp in seconds. This function is not 
deterministic which means the value would be recalculated for each record.
   - sql: UNIX_TIMESTAMP(string1[, string2])
     table: unixTimestamp(STRING1[, STRING2])
-    description: 'Converts date time string string1 in format string2 (by 
default: yyyy-MM-dd HH:mm:ss if not specified) to Unix timestamp (in seconds), 
using the specified timezone in table config.'
+    description: |
+      Converts a date time string string1 with format string2 (by default: 
yyyy-MM-dd HH:mm:ss if not specified) to Unix timestamp (in seconds), using the 
specified timezone in table config.
+      
+      If a time zone is specified in the date time string and parsed by UTC+X 
format such as "yyyy-MM-dd HH:mm:ss.SSS X", this function will use the 
specified timezone in the date time string instead of the timezone in table 
config.
+      If the date time string can not be parsed, the default value 
Long.MIN_VALUE(-9223372036854775808) will be returned.
+      
+      ```
+      SET 'table.local-time-zone' = 'Europe/Berlin';
+      
+      -- 1641020400
+      SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001', 'yyyy-MM-dd 
HH:mm:ss.SSS');
+      -- 1640995200
+      SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001 +0800', 'yyyy-MM-dd 
HH:mm:ss.SSS X');
+      -- 1641020400
+      SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001 +0800', 'yyyy-MM-dd 
HH:mm:ss.SSS');
+      -- -9223372036854775808
+      SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001', 'yyyy-MM-dd 
HH:mm:ss.SSS X');

Review Comment:
   ```suggestion
         Flink SQL> SET 'table.local-time-zone' = 'Europe/Berlin';
         
         Flink SQL> SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001', 
'yyyy-MM-dd HH:mm:ss.SSS');
         -- output: 1641020400
         Flink SQL> SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001 +0800', 
'yyyy-MM-dd HH:mm:ss.SSS X');
         -- output: 1641020400
         Flink SQL> SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001 +0800', 
'yyyy-MM-dd HH:mm:ss.SSS');
         -- output: 1640995200
         Flink SQL> SELECT UNIX_TIMESTAMP('2022-01-01 08:00:00.001', 
'yyyy-MM-dd HH:mm:ss.SSS X');
         -- output: -9223372036854775808
   ```



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