Mrart commented on code in PR #4108:
URL: https://github.com/apache/flink-cdc/pull/4108#discussion_r2297988287


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-debezium/src/main/java/org/apache/flink/cdc/debezium/event/DebeziumEventDeserializationSchema.java:
##########
@@ -472,6 +482,57 @@ protected Object convertToMap(Object dbzObj, Schema 
schema) throws Exception {
         return new GenericMapData(convertedMap);
     }
 
+    protected Object convertToArray(Object dbzObj, Schema schema) throws 
Exception {
+        if (dbzObj == null) {
+            return null;
+        }
+
+        Schema elementSchema = schema.valueSchema();
+        DataType elementType = schemaDataTypeInference.infer(null, 
elementSchema);
+        DeserializationRuntimeConverter elementConverter = 
createConverter(elementType);
+
+        if (dbzObj instanceof java.util.List) {
+            java.util.List<?> list = (java.util.List<?>) dbzObj;
+            Object[] array = new Object[list.size()];
+
+            for (int i = 0; i < list.size(); i++) {
+                Object element = list.get(i);
+                if (element != null) {
+                    if (elementSchema.type() == Schema.Type.ARRAY) {
+                        array[i] = convertToArray(element, elementSchema);
+                    } else {
+                        array[i] = elementConverter.convert(element, 
elementSchema);
+                    }
+                }
+            }
+
+            return new GenericArrayData(array);
+        } else if (dbzObj.getClass().isArray()) {
+            Object[] inputArray = (Object[]) dbzObj;
+            Object[] convertedArray = new Object[inputArray.length];
+
+            for (int i = 0; i < inputArray.length; i++) {
+                if (inputArray[i] != null) {
+                    if (elementSchema.type() == Schema.Type.ARRAY) {
+                        convertedArray[i] = convertToArray(inputArray[i], 
elementSchema);
+                    } else {
+                        convertedArray[i] = 
elementConverter.convert(inputArray[i], elementSchema);
+                    }
+                }
+            }
+
+            return new GenericArrayData(convertedArray);
+        } else {
+            Object[] array = new Object[1];

Review Comment:
   It throw exception will more reasonable?



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

Reply via email to