PatrickRen commented on code in PR #3145:
URL: https://github.com/apache/flink-cdc/pull/3145#discussion_r1559175155


##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql/src/main/java/org/apache/flink/cdc/connectors/mysql/utils/MySqlTypeUtils.java:
##########
@@ -218,7 +218,9 @@ private static DataType convertFromColumn(Column column) {
             case MULTILINESTRING:
                 return DataTypes.STRING();
             case BINARY:
-                return DataTypes.BINARY(column.length());
+                return column.length() > 0

Review Comment:
   Actually it's possible to create a `BINARY(0)` column, so we need to split 
cases where `column.length() < 0` and `column.length() == 0`:
   
   - If `column.length() < 0`, which means the column uses default length like 
`BINARY`, then we convert it to `DataTypes.BINARY(1)`
   - If `column.length() == 0`, which means the column is created intentionally 
with type `BINARY(0)`, then we should convert it to `DataTypes.BINARY(0)`. 
Considering `BinaryType` doesn't support 0 length for now, we need to add it 
like what Flink does: 
https://github.com/apache/flink/blob/dec5e9e659dd09346781c97c940a20a6cbc63678/flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/BinaryType.java#L93-L95
   
   Same issue for `CHAR` type.



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