jnh5y commented on code in PR #23633: URL: https://github.com/apache/flink/pull/23633#discussion_r1380349827
########## flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeCasts.java: ########## @@ -288,6 +288,50 @@ public static boolean supportsExplicitCast(LogicalType sourceType, LogicalType t return supportsCasting(sourceType, targetType, true); } + /** + * Returns whether the source type can be reinterpreted as the target type. + * + * <p>Reinterpret casts correspond to the SQL reinterpret_cast and represent the logic behind a + * {@code REINTERPRET_CAST(sourceType AS targetType)} operation. + */ + public static boolean supportsReinterpretCast(LogicalType sourceType, LogicalType targetType) { + if (sourceType.getTypeRoot() == targetType.getTypeRoot()) { + return true; + } + + switch (targetType.getTypeRoot()) { + case INTEGER: + switch (sourceType.getTypeRoot()) { + case DATE: + case TIME_WITHOUT_TIME_ZONE: + case INTERVAL_YEAR_MONTH: + return true; + default: + return false; + } + case BIGINT: + switch (sourceType.getTypeRoot()) { + case DATE: + case TIME_WITHOUT_TIME_ZONE: + case TIMESTAMP_WITHOUT_TIME_ZONE: + case INTERVAL_DAY_TIME: + case INTERVAL_YEAR_MONTH: + return true; + default: + return false; + } + case DATE: + case TIME_WITHOUT_TIME_ZONE: + case INTERVAL_YEAR_MONTH: + return sourceType.getTypeRoot() == INTEGER; Review Comment: Can/should DATEs, TIME_WITHOUT_TIME_ZONEs, INTERVAL_YEAR_MONTH be castable to a BIGINT? -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org