huyuanfeng2018 commented on code in PR #7620:
URL: https://github.com/apache/iceberg/pull/7620#discussion_r1205421989
##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/IcebergTableSink.java:
##########
@@ -70,9 +78,30 @@ public SinkRuntimeProvider getSinkRuntimeProvider(Context
context) {
!overwrite || context.isBounded(),
"Unbounded data stream doesn't support overwrite operation.");
- List<String> equalityColumns =
+ List<String> primaryKeys =
tableSchema.getPrimaryKey().map(UniqueConstraint::getColumns).orElseGet(ImmutableList::of);
+ List<String> partitionFields = ImmutableList.of();
+ if (Boolean.parseBoolean(writeProps.get(TableProperties.UPSERT_ENABLED))) {
+ tableLoader.open();
+ try (TableLoader loader = tableLoader) {
+ Table table = loader.loadTable();
+ if (table.spec().isPartitioned()) {
+ partitionFields =
+
table.spec().fields().stream().map(PartitionField::name).collect(Collectors.toList());
+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException(
+ "Failed to load iceberg table from table loader: " + tableLoader,
e);
+ }
+ }
+
+ List<String> equalityColumns =
Review Comment:
In this way, only the same primary key data in the partition will be upsert
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]