-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][Jdbc-Connector] Add OceanBase Connector #4626
Changes from all commits
7e881a3
6942728
fc2b53a
4feacd7
c2b59a7
f007a2b
e9c4289
cd2171e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
<redshift.version>2.1.0.9</redshift.version> | ||
<saphana.version>2.14.7</saphana.version> | ||
<vertica.version>12.0.3-0</vertica.version> | ||
<oceanbase.version>2.4.2</oceanbase.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not be imported directly due to the lgpl license https://github.com/oceanbase/obconnector-j |
||
</dependencies> | ||
</dependencyManagement> | ||
|
||
|
@@ -144,7 +151,10 @@ | |
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
<groupId>com.oceanbase</groupId> | ||
<artifactId>oceanbase-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* A factory to create a specific {@link JdbcDialect} | ||
* | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the default JdbcDialect create(String driverType) {
return create();
} |
||
boolean acceptsURL(String url, Optional<String> driverTye); | ||
|
||
/** @return Creates a new instance of the {@link JdbcDialect}. */ | ||
JdbcDialect create(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add example into docs |
||
} | ||
|
||
@Override | ||
public JdbcDialect create() { | ||
return new MysqlDialect(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can merge the two dialect classes of OceanBase and return the JdbcDialect by the public JdbcDialect create(@Nonnull String driverType) {
if ("mysql".equalsIgnoreCase(driverType)) {
return new MysqlDialect();
}
return new OracleDialect();
} |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.oracle.OracleDialect; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
import java.util.Optional; | ||
|
||
@AutoService(JdbcDialectFactory.class) | ||
public class OceanBaseOracleDialectFactory implements JdbcDialectFactory { | ||
@Override | ||
public boolean acceptsURL(String url, Optional<String> driverTye) { | ||
return url.startsWith("jdbc:oceanbase:") | ||
&& driverTye.isPresent() | ||
&& driverTye.get().equalsIgnoreCase("oracle"); | ||
} | ||
|
||
@Override | ||
public JdbcDialect create() { | ||
return new OracleDialect(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add appendix & axample
https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/connector-v2/source/Jdbc.md#appendix