Skip to content
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][Connector-V2][JDBC] support sqlite Source & Sink #3089

Merged
merged 32 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
04e2395
refactor JDBC[SqLite] connector
nutsjian Oct 13, 2022
cf1ddc4
[Improve] [JDBC] [SQLite] Connector test more field types
nutsjian Oct 14, 2022
2981c1a
add [JDBC] [SQLite] doc
nutsjian Oct 14, 2022
0643e4a
fix [JDBC] [SQLite] e2e test case method name
nutsjian Oct 14, 2022
f3de959
[fix] class name error
nutsjian Oct 15, 2022
6f3b792
[Hotfix] [JDBC] [SQLite] connector e2e test path problem
nutsjian Oct 15, 2022
e4bf558
[fix] [JDBC] [SQLite] flink e2e test docker container db file cannot …
nutsjian Oct 18, 2022
45701f3
[fix] [JDBC] [SQLite] flink e2e test
nutsjian Oct 19, 2022
7bd5125
Merge branch 'dev' into jdbc-sqlite
nutsjian Oct 19, 2022
e587104
[fix] [JDBC] [SQLite] flink e2e test database closed error
nutsjian Oct 20, 2022
049f6c7
Merge branch 'dev' into jdbc-sqlite
nutsjian Oct 20, 2022
803dec9
Merge branch 'dev' into jdbc-sqlite
nutsjian Oct 20, 2022
ce5ddf0
[fix] [JDBC] [SQLite] e2e test, rerun workflows commit
nutsjian Oct 24, 2022
eb321b0
Merge branch 'dev' into jdbc-sqlite
nutsjian Oct 28, 2022
0118847
update [JDBC] [SQLite] add change log
nutsjian Nov 1, 2022
7ef5bfe
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 1, 2022
d5ed310
update [JDBC] [SQLite] change log doc
nutsjian Nov 1, 2022
a861767
update [JDBC] [SQLite] connector map tinyint smallint to SeaTunnel Sh…
nutsjian Nov 8, 2022
8fbaad8
refactor JDBC[SqLite] connector
nutsjian Oct 13, 2022
dfd660c
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 11, 2022
93468b5
update, merge upstream dev, add e2e in flink/spark e2e module so that…
nutsjian Nov 11, 2022
18cf506
update checkstyle
nutsjian Nov 11, 2022
70494ae
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 15, 2022
03fba9f
[checkstyle] remove unused import
nutsjian Nov 15, 2022
976c5a6
Merge remote-tracking branch 'upstream' into jdbc-sqlite
nutsjian Nov 15, 2022
6197196
Merge branch 'dev' of https://github.com/apache/incubator-seatunnel i…
nutsjian Nov 16, 2022
d03bf4d
update [JDBC] [SQLite] connector
nutsjian Nov 16, 2022
5ad4b4c
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 18, 2022
fa00b72
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 18, 2022
5c0b7e8
Merge branch 'dev' into jdbc-sqlite
nutsjian Nov 22, 2022
f4d4d33
fix [JDBC] [SQLite] connector, remove root pom.xml dup net.alchim31.m…
nutsjian Nov 22, 2022
3204610
update [Connector] [JDBC] SQLite, remove typeAffinity option, impleme…
nutsjian Nov 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/en/connector-v2/sink/Jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ there are some reference value for params above.
| Phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | / | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client |
| SQL Server | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:sqlserver://localhost:1433 | com.microsoft.sqlserver.jdbc.SQLServerXADataSource | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc |
| Oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | oracle.jdbc.xa.OracleXADataSource | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 |
| sqlite | org.sqlite.JDBC | jdbc:sqlite:test.db | / | https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc |
| GBase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | / | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar |
| StarRocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | / | https://mvnrepository.com/artifact/mysql/mysql-connector-java |
| db2 | com.ibm.db2.jcc.DB2Driver | jdbc:db2://localhost:50000/testdb | com.ibm.db2.jcc.DB2XADataSource | https://mvnrepository.com/artifact/com.ibm.db2.jcc/db2jcc/db2jcc4 |
Expand Down Expand Up @@ -199,4 +200,5 @@ sink {

### next version

- [Feature] Support Sqlite JDBC Sink ([3089](https://github.com/apache/incubator-seatunnel/pull/3089))
- [Feature] Support CDC write DELETE/UPDATE/INSERT events ([3378](https://github.com/apache/incubator-seatunnel/issues/3378))
2 changes: 2 additions & 0 deletions docs/en/connector-v2/source/Jdbc.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ there are some reference value for params above.
| phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client |
| sqlserver | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:sqlserver://localhost:1433 | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc |
| oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 |
| sqlite | org.sqlite.JDBC | jdbc:sqlite:test.db | https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc |
| gbase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar |
| starrocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | https://mvnrepository.com/artifact/mysql/mysql-connector-java |
| db2 | com.ibm.db2.jcc.DB2Driver | jdbc:db2://localhost:50000/testdb | https://mvnrepository.com/artifact/com.ibm.db2.jcc/db2jcc/db2jcc4 |
Expand Down Expand Up @@ -156,5 +157,6 @@ parallel:
### next version

- [BugFix] Fix jdbc split bug ([3220](https://github.com/apache/incubator-seatunnel/pull/3220))
- [Feature] Support Sqlite JDBC Source ([3089](https://github.com/apache/incubator-seatunnel/pull/3089))
- [Feature] Support Tablestore Source ([3309](https://github.com/apache/incubator-seatunnel/pull/3309))
- [Feature] Support JDBC Fetch Size Config ([3478](https://github.com/apache/incubator-seatunnel/pull/3478))
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -841,12 +841,6 @@
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
14 changes: 12 additions & 2 deletions seatunnel-connectors-v2/connector-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
<sqlserver.version>9.2.1.jre8</sqlserver.version>
<phoenix.version>5.2.5-HBase-2.x</phoenix.version>
<oracle.version>12.2.0.1</oracle.version>
<sqlite.version>3.39.3.0</sqlite.version>
<db2.version>db2jcc4</db2.version>
<sqlite.version>3.39.3.0</sqlite.version>
<tablestore.version>5.13.9</tablestore.version>
</properties>

Expand Down Expand Up @@ -78,20 +80,24 @@
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc</artifactId>
<version>${db2.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>tablestore-jdbc</artifactId>
<version>${tablestore.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -129,6 +135,10 @@
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static JdbcConnectionOptions buildJdbcConnectionOptions(Config config) {
jdbcOptions.transactionTimeoutSec = config.getInt(JdbcConfig.TRANSACTION_TIMEOUT_SEC.key());
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert it.

return jdbcOptions;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.sqlite;

import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Collectors;

public class SqliteDialect implements JdbcDialect {
@Override
public String dialectName() {
return "Sqlite";
}

@Override
public JdbcRowConverter getRowConverter() {
return new SqliteJdbcRowConverter();
}

@Override
public JdbcDialectTypeMapper getJdbcDialectTypeMapper() {
return new SqliteTypeMapper();
}

@Override
public String quoteIdentifier(String identifier) {
return "`" + identifier + "`";
}

@Override
public Optional<String> getUpsertStatement(String tableName, String[] fieldNames, String[] uniqueKeyFields) {
String updateClause = Arrays.stream(fieldNames)
.map(fieldName -> quoteIdentifier(fieldName) + "=VALUES(" + quoteIdentifier(fieldName) + ")")
.collect(Collectors.joining(", "));

String conflictFields = Arrays.stream(uniqueKeyFields)
.map(this::quoteIdentifier)
.collect(Collectors.joining(","));

String upsertSQL = getInsertIntoStatement(tableName, fieldNames) + " ON CONFLICT(" + conflictFields + ") DO UPDATE SET " + updateClause;
return Optional.of(upsertSQL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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.sqlite;

import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory;

import com.google.auto.service.AutoService;

/**
* Factory for {@link SqliteDialect}.
*/

@AutoService(JdbcDialectFactory.class)
public class SqliteDialectFactory implements JdbcDialectFactory {
@Override
public boolean acceptsURL(String url) {
return url.startsWith("jdbc:sqlite:");
}

@Override
public JdbcDialect create() {
return new SqliteDialect();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.sqlite;

import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.AbstractJdbcRowConverter;

public class SqliteJdbcRowConverter extends AbstractJdbcRowConverter {

@Override
public String converterName() {
return "Sqlite";
}

}
Loading