raminqaf commented on code in PR #27793:
URL: https://github.com/apache/flink/pull/27793#discussion_r2971881771


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/TimeFunctionsITCase.java:
##########
@@ -811,6 +813,71 @@ private Stream<TestSetSpec> floorTestCases() {
                                 STRING().nullable()));
     }
 
+    private Stream<TestSetSpec> toTimestampTestCases() {
+        return Stream.of(
+                
TestSetSpec.forFunction(BuiltInFunctionDefinitions.TO_TIMESTAMP)
+                        .onFieldsWithData("unparsable", null)
+                        .andDataTypes(STRING(), STRING().nullable())
+                        // 1-arg: default format, returns TIMESTAMP(3)
+                        .testResult(
+                                toTimestamp("2023-01-01 12:30:00"),
+                                "TO_TIMESTAMP('2023-01-01 12:30:00')",
+                                LocalDateTime.of(2023, 1, 1, 12, 30, 0),
+                                TIMESTAMP(3).nullable())

Review Comment:
   Added the tests



##########
docs/data/sql_functions.yml:
##########
@@ -722,7 +722,21 @@ temporal:
       TO_TIMESTAMP_LTZ('2023-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss', 
'Asia/Shanghai') parses in Shanghai time zone.
   - sql: TO_TIMESTAMP(string1[, string2])
     table: toTimestamp(STRING1[, STRING2])
-    description: "Converts date time string string1 with format string2 (by 
default: 'yyyy-MM-dd HH:mm:ss') to a timestamp, without time zone."
+    description: |
+      Converts a datetime string to a TIMESTAMP without time zone.
+
+      - string1: the datetime string to parse
+      - string2: the format pattern (default 'yyyy-MM-dd HH:mm:ss'). The 
pattern follows Java's DateTimeFormatter syntax, where 'S' represents 
fractional seconds (e.g., 'SSS' for milliseconds, 'SSSSSS' for microseconds, 
'SSSSSSSSS' for nanoseconds).
+
+      The output precision depends on the variant used:
+      - 1-arg variant: always returns TIMESTAMP(3).
+      - 2-arg variant: precision is inferred from the number of trailing 'S' 
characters in the format pattern, with a minimum of 3. E.g., format 'yyyy-MM-dd 
HH:mm:ss.SS' returns TIMESTAMP(3), format 'yyyy-MM-dd HH:mm:ss.SSSSSS' returns 
TIMESTAMP(6).

Review Comment:
   I have added some tests and updated the docs



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