DongLiang-0 commented on code in PR #25:
URL: 
https://github.com/apache/doris-kafka-connector/pull/25#discussion_r1627330848


##########
src/main/java/org/apache/doris/kafka/connector/converter/type/debezium/ArrayType.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.doris.kafka.connector.converter.type.debezium;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import org.apache.doris.kafka.connector.cfg.DorisOptions;
+import org.apache.doris.kafka.connector.converter.RecordTypeRegister;
+import org.apache.doris.kafka.connector.converter.type.AbstractType;
+import org.apache.doris.kafka.connector.converter.type.Type;
+import org.apache.doris.kafka.connector.converter.type.doris.DorisType;
+import org.apache.kafka.connect.data.Schema;
+
+public class ArrayType extends AbstractType {
+    DorisOptions dorisOptions;
+    private static final String ARRAY_TYPE_TEMPLATE = "%s<%s>";
+    public static final ArrayType INSTANCE = new ArrayType();
+
+    @Override
+    public void configure(DorisOptions dorisOptions) {
+        this.dorisOptions = dorisOptions;
+    }
+
+    @Override
+    public String[] getRegistrationKeys() {
+        return new String[] {"ARRAY"};
+    }
+
+    @Override
+    public String getTypeName(Schema schema) {
+        if (schema.valueSchema().isOptional()) {
+            Schema valueSchema = schema.valueSchema();
+            String type =
+                    Objects.nonNull(valueSchema.name())
+                            ? valueSchema.name()
+                            : valueSchema.type().name();
+            Type valueType = new 
RecordTypeRegister(dorisOptions).getTypeRegistry().get(type);
+            if (valueType == null) {
+                return DorisType.STRING;
+            }
+            String typeName = valueType.getTypeName(schema);
+            return String.format(ARRAY_TYPE_TEMPLATE, DorisType.ARRAY, 
typeName);
+        }
+        return DorisType.STRING;
+    }
+
+    @Override
+    public Object getValue(Object sourceValue, Schema schema) {
+
+        if (sourceValue == null) {
+            return null;
+        }
+        Schema valueSchema = schema.valueSchema();
+        String type =
+                Objects.nonNull(valueSchema.name())
+                        ? valueSchema.name()
+                        : valueSchema.type().name();
+
+        if (sourceValue instanceof ArrayList) {

Review Comment:
   Would it be better to change this to ```sourceValue instanceof List```?



##########
src/main/java/org/apache/doris/kafka/connector/converter/type/doris/DorisType.java:
##########


Review Comment:
   Are the changes in this file a bit redundant? I didn’t find where to quote 
them.



-- 
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: dev-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to