geserdugarov commented on code in PR #12104:
URL: https://github.com/apache/hudi/pull/12104#discussion_r1808082293


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteFunction.java:
##########
@@ -463,16 +439,15 @@ private void registerMetrics() {
     writeMetrics.registerMetrics();
   }
 
-  protected List<WriteStatus> writeBucket(String instant, DataBucket bucket, 
List<HoodieRecord> records) {
-    bucket.preWrite(records);
+  protected List<WriteStatus> writeRecords(String instant, List<HoodieRecord> 
records) {
     writeMetrics.startFileFlush();
-    List<WriteStatus> statuses = writeFunction.apply(records, instant);
+    List<WriteStatus> statuses = 
writeFunction.apply(deduplicateRecordsIfNeeded(records), instant);

Review Comment:
   But `preWrite` doesn't update instant time, and uses instant time of some 
new first record after deduplication:
   
https://github.com/apache/hudi/blob/47e5dddf7e64f79728398233314faf72c02e5283/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteFunction.java#L240-L247
   
   We use `first = records.get(0)` for `preWrite`, which means, that `first` is 
**some random record after deduplication** if the initial first one has been 
removed.
   And we **use almost all from this random record as it is**:
   - `first.getKey()`
   - `first.getData()`
   - `first.getOperation()`
   - **`first.getCurrentLocation().getInstantTime()`**  <--
   
   including instant time. The only difference is `fileID`, which is the same 
for all records in `DataBucket`, because `fileID` defines `bucketID`:
   
https://github.com/apache/hudi/blob/47e5dddf7e64f79728398233314faf72c02e5283/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/util/StreamerUtil.java#L317-L318
   



-- 
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]

Reply via email to