raminqaf commented on code in PR #28758:
URL: https://github.com/apache/flink/pull/28758#discussion_r3702656723
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/casting/CastRulesTest.java:
##########
@@ -1544,35 +1544,79 @@ Stream<CastTestSpecBuilder> testCases() {
.fromCase(BITMAP(), DEFAULT_BITMAP,
DEFAULT_BITMAP.toBytes())
.fromCase(BITMAP(), Bitmap.empty(),
Bitmap.empty().toBytes())
.fromCase(BITMAP(), null, null),
- // From VARIANT to primitive types. Numeric targets are
lenient: a variant holding
- // any numeric kind converts to the requested numeric type
(widening and narrowing).
- // Non-numeric targets are strict: the stored kind must match,
otherwise the cast
- // fails and TRY_CAST returns null.
+ // From VARIANT to primitive types. A cast succeeds only when
the target holds the
+ // stored value unaltered, except for the approximate FLOAT
and DOUBLE.
+ // A character string renders like a regular cast of the
stored kind, so these
+ // expectations reuse the constants of the native cases above.
+ CastTestSpecBuilder.testCastTo(STRING())
+ .fromCase(VARIANT(), Variant.newBuilder().of(true),
fromString("TRUE"))
+ .fromCase(VARIANT(), Variant.newBuilder().of(false),
fromString("FALSE"))
+ .fromCase(VARIANT(), Variant.newBuilder().of("foo"),
fromString("foo"))
+ .fromCase(VARIANT(), Variant.newBuilder().of(42),
fromString("42"))
+ .fromCase(
+ VARIANT(),
+ Variant.newBuilder().of(new
BigDecimal("123.456")),
+ fromString("123.456"))
+ .fromCase(
+ VARIANT(),
+
Variant.newBuilder().of(LocalDate.parse("2021-09-24")),
+ DATE_STRING)
+ .fromCase(
+ VARIANT(),
+
Variant.newBuilder().of(TIMESTAMP.toLocalDateTime()),
+ TIMESTAMP_STRING)
+ .fromCase(
+ VARIANT(),
+ CET_CONTEXT,
+ Variant.newBuilder().of(TIMESTAMP.toInstant()),
+ TIMESTAMP_STRING_CET)
+ // a binary value has no scalar rendering
Review Comment:
A binary value now decodes as UTF-8, the same as a regular BINARY to string
cast
--
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]