nsivabalan commented on code in PR #13295:
URL: https://github.com/apache/hudi/pull/13295#discussion_r2103912129


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/SparkRDDWriteClient.java:
##########
@@ -148,6 +152,24 @@ public JavaRDD<WriteStatus> 
upsertPreppedRecords(JavaRDD<HoodieRecord<T>> preppe
     return postWrite(resultRDD, instantTime, table);
   }
 
+  /**
+   * Used for streaming writes to metadata table.
+   */
+  @Override
+  public JavaRDD<WriteStatus> upsertPreppedRecords(JavaRDD<HoodieRecord<T>> 
preppedRecords, String instantTime, Option<List<Pair<String, String>>> 
partitionFileIdPairsOpt) {
+    ValidationUtils.checkArgument(isMetadataTable, "This version of upsert 
prepped can only be invoked for metadata table");
+    HoodieTable<T, HoodieData<HoodieRecord<T>>, HoodieData<HoodieKey>, 
HoodieData<WriteStatus>> table =
+        initTable(WriteOperationType.UPSERT_PREPPED, 
Option.ofNullable(instantTime));
+    table.validateUpsertSchema();
+    if (!(partitionFileIdPairsOpt.isPresent() && 
partitionFileIdPairsOpt.get().get(0).getKey().equals(FILES.getPartitionPath())))
 {
+      // we do not want to call prewrite more than once for the same instant 
writing to metadata table twice.

Review Comment:
   Alternate idea I had was to maintain a set<String> i.e. Set<Instant time> 
for which pre-write is already invoked. But since this is only applicable for 
MDT, did not want to make this generic or all cases. If we might have use-cases 
for data table, where we might wanna do similar things 
   i.e. 
   ```
   t1 = writeClient.startCommit()
   writeClient.upsert(batch1, t1)
   writeClient.upsert(batch2, t1)
   writeClient.commit 
   ```
   
   then may be, we can make a justification for add a hashset to writeClient 
class.



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