twalthr commented on a change in pull request #17811:
URL: https://github.com/apache/flink/pull/17811#discussion_r759478145



##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sink/ConstraintEnforcer.java
##########
@@ -227,22 +243,34 @@ public void processElement(StreamRecord<RowData> element) 
throws Exception {
 
         final RowData rowData = element.getValue();
 
-        boolean trimmed = false;
+        boolean trimmedOrPadded = false;
         for (int i = 0; i < charFieldIndices.length; i++) {
             final int fieldIdx = charFieldIndices[i];
             final int precision = charFieldPrecisions[i];
             final BinaryStringData stringData = (BinaryStringData) 
rowData.getString(fieldIdx);
+            final int sourceStrLength = stringData.numChars();
 
-            if (stringData.numChars() > precision) {
-                if (!trimmed) {
+            if (charFieldShouldPad.get(i) && sourceStrLength < precision) {
+                if (!trimmedOrPadded) {
+                    reusableRowData.setRow(rowData);
+                }
+                byte[] newString = new byte[precision];

Review comment:
       thanks for the investigation sounds good to me :)




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


Reply via email to