snuyanzin commented on code in PR #30214:
URL: https://github.com/apache/flink/pull/30214#discussion_r4754539851
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/casting/CastRulesTest.java:
##########
@@ -669,6 +669,41 @@ Stream<CastTestSpecBuilder> testCases() {
STRING(),
fromString("2021-09-27 12:34:56.123456789"),
DateTimeUtils.toInternal(LocalDate.of(2021, 9,
27)))
+ .fromCase(
+ STRING(),
+ fromString("2021-09"),
+ DateTimeUtils.toInternal(LocalDate.of(2021, 9,
1)))
+ // the hyphens after the first space are not part of
the date
+ .fromCase(
+ STRING(),
+ fromString("2021 09-27"),
+ DateTimeUtils.toInternal(LocalDate.of(2021, 1,
1)))
+ .fromCase(
+ STRING(),
+ fromString("2021-09 27-01"),
+ DateTimeUtils.toInternal(LocalDate.of(2021, 9,
1)))
+ .fromCase(
+ STRING(),
+ fromString("2021-9-7"),
+ DateTimeUtils.toInternal(LocalDate.of(2021, 9,
7)))
+ // a leading space doesn't end the date
+ .fromCase(
+ STRING(),
+ fromString(" 2021-09-27"),
+ DateTimeUtils.toInternal(LocalDate.of(2021, 9,
27)))
+ .fail(STRING(), fromString(""),
TableRuntimeException.class)
+ .fail(STRING(), fromString("2021--27"),
TableRuntimeException.class)
+ .fail(STRING(), fromString("2021-0x-27"),
TableRuntimeException.class)
+ .fail(STRING(), fromString("2021-13-01"),
TableRuntimeException.class)
+ .fail(STRING(), fromString("2021-02-29"),
TableRuntimeException.class)
+ .fail(
+ STRING(),
+ fromString("99999999999-01-01"),
+ TableRuntimeException.class)
+ .fail(
+ STRING(),
+ fromString("99999999999a-01-01"),
+ TableRuntimeException.class)
Review Comment:
added,
--
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]