This is an automated email from the ASF dual-hosted git repository.
arshad pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/seatunnel-web.git
The following commit(s) were added to refs/heads/main by this push:
new 33513dd4 [Improve][DB2] Use generate_sink_sql=true for db2 upsert
(#233)
33513dd4 is described below
commit 33513dd4f2dd090a4893ec340bb4d85fd1cdf20d
Author: Shashwat Tiwari <[email protected]>
AuthorDate: Mon Oct 21 19:17:38 2024 +0530
[Improve][DB2] Use generate_sink_sql=true for db2 upsert (#233)
Signed-off-by: Mohammad Arshad <[email protected]>
---
.../impl/Db2DataSourceConfigSwitcher.java | 46 ----------------------
1 file changed, 46 deletions(-)
diff --git
a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/Db2DataSourceConfigSwitcher.java
b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/Db2DataSourceConfigSwitcher.java
index 022148d6..a9277c2d 100644
---
a/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/Db2DataSourceConfigSwitcher.java
+++
b/seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/thirdparty/datasource/impl/Db2DataSourceConfigSwitcher.java
@@ -42,9 +42,6 @@ import static
org.apache.seatunnel.app.domain.request.connector.BusinessMode.DAT
public class Db2DataSourceConfigSwitcher extends
BaseJdbcDataSourceConfigSwitcher {
private static final String QUERY_KEY = "query";
-
- private static final String GENERATE_SINK_SQL = "generate_sink_sql";
-
private static final String URL_KEY = "url";
// for catalog
@@ -109,16 +106,6 @@ public class Db2DataSourceConfigSwitcher extends
BaseJdbcDataSourceConfigSwitche
connectorConfig =
connectorConfig.withValue(QUERY_KEY,
ConfigValueFactory.fromAnyRef(sql));
- } else if (pluginType.equals(PluginType.SINK)) {
-
- List<String> tableFields = selectTableFields.getTableFields();
-
- String sql = generateDb2(tableFields, databaseName, tableName);
-
- connectorConfig =
- connectorConfig.withValue(QUERY_KEY,
ConfigValueFactory.fromAnyRef(sql));
- } else {
- throw new UnsupportedOperationException("Unsupported plugin
type: " + pluginType);
}
return super.mergeDatasourceConfig(
@@ -185,10 +172,6 @@ public class Db2DataSourceConfigSwitcher extends
BaseJdbcDataSourceConfigSwitche
return generateSql(tableFields, database, null, table);
}
- protected String generateDb2(List<String> tableFields, String database,
String table) {
- return generateSinkSql(tableFields, database, null, table);
- }
-
protected String generateSql(
List<String> tableFields, String database, String schema, String
table) {
StringBuilder sb = new StringBuilder();
@@ -208,35 +191,6 @@ public class Db2DataSourceConfigSwitcher extends
BaseJdbcDataSourceConfigSwitche
return "\"" + identifier + "\"";
}
- protected String generateSinkSql(
- List<String> tableFields, String database, String schema, String
table) {
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT INTO ")
- .append(quoteIdentifier(database) + "." +
quoteIdentifier(table))
- .append(" (");
-
- // Append column names
- for (int i = 0; i < tableFields.size(); i++) {
- sb.append(quoteIdentifier(tableFields.get(i)));
- if (i < tableFields.size() - 1) {
- sb.append(", ");
- }
- }
-
- sb.append(") VALUES (");
-
- // Append placeholders
- for (int i = 0; i < tableFields.size(); i++) {
- sb.append("?");
- if (i < tableFields.size() - 1) {
- sb.append(", ");
- }
- }
-
- sb.append(");");
- return sb.toString();
- }
-
@Override
public String getDataSourceName() {
return "JDBC-DB2";