1
0
Эх сурвалжийг харах

SQL: [Docs] Fix TIME_PARSE documentation (#58182)

TIME_PARSE works correctly if both date and time parts are specified,
and a TIME object (that contains only time is returned).

Adjust docs and add a unit test that validates the behavior.

Follows: #55223
Marios Trivyzas 5 жил өмнө
parent
commit
9d6b679a5d

+ 1 - 1
docs/reference/sql/functions/date-time.asciidoc

@@ -520,7 +520,7 @@ https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/time/format/Da
 If any of the two arguments is `null` or an empty string `null` is returned.
 
 [NOTE]
-If the parsing pattern contains date units (e.g. 'dd/MM/uuuu', 'dd-MM HH:mm:ss', etc.) an error is returned
+If the parsing pattern contains only date units (e.g. 'dd/MM/uuuu') an error is returned
 as the function needs to return a value of `time` type which will contain only time.
 
 [source, sql]

+ 6 - 0
x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/expression/function/scalar/datetime/DateTimeParseProcessorTests.java

@@ -203,5 +203,11 @@ public class DateTimeParseProcessorTests extends AbstractSqlWireSerializingTestC
                 .asProcessor()
                 .process(null)
         );
+        assertEquals(
+            time(10, 20, 30, 123456789, ZoneOffset.of("+05:30"), zoneId),
+            new TimeParse(Source.EMPTY, l("16/06/2020 10:20:30.123456789 +05:30"), l("dd/MM/uuuu HH:mm:ss.SSSSSSSSS zz"), zoneId).makePipe()
+                .asProcessor()
+                .process(null)
+        );
     }
 }