nzw921rx commented on PR #10897:
URL: https://github.com/apache/seatunnel/pull/10897#issuecomment-4474984050
> > @chl-wxp Hello, may I ask why this parameter is being cleared? It seems
to be an entry that only wants to `insert` and not `update`?
>
> Thank you for your review. When I reviewed the code, I found that the
final behavior controlled by the parameter `support_upsert_by_insert_only` is
to insert data using insert syntax. When we want to achieve this goal, we only
need to set the parameter `enable_upsert` to false. Another very important
point is that there is no introduction to the `support_upsert_by_insert_only`
parameter in earlier versions.
@chl-wxp Thank you for your clarification. I still have the following
concerns
- When `enable_upsert = false`, the semantics and behavior of
`createInsertOrUpdateExecutor` differ from those of `createInsertOnlyExecutor`.
- There has been a continued compatibility impact for users of this
parameter. Since the `support_upsert-by_insert_only` parameter was not
available in early versions, we cannot rule out the possibility that some users
depended on it. This may lead to unexpected behavior for these users after
upgrading.
```java
private static JdbcBatchStatementExecutor<SeaTunnelRow> createUpsertExecutor(
JdbcDialect dialect,
String database,
String table,
TableSchema tableSchema,
TableSchema databaseTableSchema,
String[] pkNames,
TableSchema pkTableSchema,
Function<SeaTunnelRow, SeaTunnelRow> keyExtractor,
boolean enableUpsert,
boolean isPrimaryKeyUpdated,
boolean supportUpsertByInsertOnly) {
if (supportUpsertByInsertOnly) {
return createInsertOnlyExecutor(
dialect, database, table, tableSchema,
databaseTableSchema);
}
if (enableUpsert) {
Optional<String> upsertSQL =
dialect.getUpsertStatementByTableSchema(database, table,
tableSchema, pkNames);
if (upsertSQL.isPresent()) {
return createSimpleExecutor(
upsertSQL.get(),
tableSchema,
databaseTableSchema,
dialect.getRowConverter());
}
return createInsertOrUpdateByQueryExecutor(
dialect,
database,
table,
tableSchema,
databaseTableSchema,
pkNames,
pkTableSchema,
keyExtractor,
isPrimaryKeyUpdated);
}
return createInsertOrUpdateExecutor(
dialect,
database,
table,
tableSchema,
databaseTableSchema,
pkNames,
isPrimaryKeyUpdated);
}
```
--
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]