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

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
(cherry picked from commit 9d6b679a5da88f3c131b9bdba49aa92c6c272abe)
This commit is contained in:
Marios Trivyzas 2020-06-18 16:09:13 +02:00 committed by GitHub
parent 3b511fd829
commit 50b391e91b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

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

View File

@ -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 +0530"), l("dd/MM/uuuu HH:mm:ss.SSSSSSSSS xx"), zoneId).makePipe()
.asProcessor()
.process(null)
);
}
}