matriv commented on a change in pull request #18063:
URL: https://github.com/apache/flink/pull/18063#discussion_r765829953
##########
File path:
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/functions/casting/CastRuleUtils.java
##########
@@ -163,6 +166,25 @@ static String binaryWriterWriteNull(
return CodeGenUtils.binaryWriterWriteNull(indexTerm, writerTerm,
logicalType);
}
+ static String lengthExceedsPrecision(String strTerm, int precision) {
+ return methodCall(strTerm, "length") + " > " + precision;
+ }
+
+ /**
+ * For complex types such as {@link LogicalTypeRoot#ARRAY}, use {@link
VarCharType#STRING_TYPE}
+ * to avoid trimming/padding when casting the inner elements to a {@link
+ * LogicalTypeRoot#VARCHAR} or {@link LogicalTypeRoot#CHAR}.
+ */
+ static LogicalType getLogicalTypeForInnerCast(LogicalType logicalType) {
+ return logicalType.is(LogicalTypeFamily.CHARACTER_STRING)
+ ? VarCharType.STRING_TYPE
+ : logicalType;
+ }
+
+ static boolean shouldPossiblyTrim(int precision) {
+ return precision < VarCharType.MAX_LENGTH;
+ }
Review comment:
I could also move the `shouldPossiblyTrim()` (as the other I'll remove)
to the `AnyToCharVarchar` class.
--
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]