whhe commented on code in PR #4626:
URL: https://github.com/apache/seatunnel/pull/4626#discussion_r1243608747


##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oceanbase/OceanBaseMySqlDialectFactory.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oceanbase;
+
+import 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
+import 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory;
+import 
org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MysqlDialect;
+
+import com.google.auto.service.AutoService;
+
+import java.util.Optional;
+
+@AutoService(JdbcDialectFactory.class)
+public class OceanBaseMySqlDialectFactory implements JdbcDialectFactory {
+    @Override
+    public boolean acceptsURL(String url, Optional<String> driverTye) {
+        return url.startsWith("jdbc:oceanbase:")
+                && driverTye.isPresent()
+                && driverTye.get().equalsIgnoreCase("mysql");
+    }
+
+    @Override
+    public JdbcDialect create() {
+        return new MysqlDialect();

Review Comment:
   We can merge the two dialect classes of OceanBase and return the JdbcDialect 
by the `driverType` param here.
   
   ```java
   public JdbcDialect create(@Nonnull String driverType) {
       if ("mysql".equalsIgnoreCase(driverType)) {
           return new MysqlDialect();
       }
       return new OracleDialect();
   }
   ```



##########
seatunnel-dist/pom.xml:
##########
@@ -488,6 +489,12 @@
                 </dependency>
 
                 <!-- jdbc driver -->
+                <dependency>
+                    <groupId>com.alipay.oceanbase</groupId>
+                    <artifactId>oceanbase-client</artifactId>
+                    <version>${oceanbase.version}</version>
+                    <scope>provided</scope>
+                </dependency>

Review Comment:
   Should not use the previous internal version, just keep it same with 
`seatunnel-connectors-v2/connector-jdbc/pom.xml`



##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/connector-jdbc-e2e-part-2/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/JdbcOceanbaseIT.java:
##########
@@ -0,0 +1,139 @@
+/*
+ * 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.seatunnel.connectors.seatunnel.jdbc;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+
+import org.apache.commons.lang3.tuple.Pair;
+
+import org.junit.jupiter.api.Disabled;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.DockerLoggerFactory;
+
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Disabled("Disabled because it needs user's personal oceanbase account to run 
this test!")
+public class JdbcOceanbaseIT extends AbstractJdbcIT {
+    private static final String OCEANBASE_IMAGE = "shihd/oceanbase:1.0";

Review Comment:
   You can use the docker image `oceanbase/oceanbase-ce:4.0.0.0` with user 
`root` and empty password.



##########
seatunnel-connectors-v2/connector-jdbc/pom.xml:
##########
@@ -129,6 +130,12 @@
                 <version>${vertica.version}</version>
                 <scope>provided</scope>
             </dependency>
+            <dependency>
+                <groupId>com.oceanbase</groupId>
+                <artifactId>oceanbase-client</artifactId>
+                <version>${oceanbase.version}</version>
+                <scope>provided</scope>
+            </dependency>

Review Comment:
   It should not be imported directly due to the lgpl license 
https://github.com/oceanbase/obconnector-j



##########
seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/JdbcDialectFactory.java:
##########
@@ -33,7 +35,7 @@ public interface JdbcDialectFactory {
      * @return <code>true</code> if this dialect understands the given URL; 
<code>false</code>
      *     otherwise.
      */
-    boolean acceptsURL(String url);

Review Comment:
   I think the `driverType` param shoud be passed in the create method below, 
and we can use a new default method to keep the other dialects unchanged.
   
   ```java
   default JdbcDialect create(String driverType) {
       return create();
   }
   ```



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