You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "vinlee19 (via GitHub)" <gi...@apache.org> on 2024/06/03 10:11:51 UTC

[PR] [feature] Support importing MySQL geographic data types and PostgreSQL array data types [doris-kafka-connector]

vinlee19 opened a new pull request, #25:
URL: https://github.com/apache/doris-kafka-connector/pull/25

   1. The Geometry data type in MySQL will be converted to a JSON-formatted string. For example, the data `ST_GeomFromText('POINT(3 1)') ` will be converted to a JSON string:
   ```
   {"coordinates":[3,1],"type":"Point","srid":0}
   ```
   
   2. Support importing array data types in PostgreSQL.
   


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [feature] Support importing MySQL geographic data types and PostgreSQL array data types [doris-kafka-connector]

Posted by "vinlee19 (via GitHub)" <gi...@apache.org>.
vinlee19 commented on PR #25:
URL: https://github.com/apache/doris-kafka-connector/pull/25#issuecomment-2147047944

   > Can we add a unit test case?
   done


-- 
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-unsubscribe@doris.apache.org

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


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


Re: [PR] [feature] Support importing MySQL geographic data types and PostgreSQL array data types [doris-kafka-connector]

Posted by "JNSimba (via GitHub)" <gi...@apache.org>.
JNSimba merged PR #25:
URL: https://github.com/apache/doris-kafka-connector/pull/25


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [feature] Support importing MySQL geographic data types and PostgreSQL array data types [doris-kafka-connector]

Posted by "DongLiang-0 (via GitHub)" <gi...@apache.org>.
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-unsubscribe@doris.apache.org

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


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