You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/11/12 19:38:25 UTC

[GitHub] [hudi] rmpifer commented on a change in pull request #2248: Update HoodieKey when deduplicating records

rmpifer commented on a change in pull request #2248:
URL: https://github.com/apache/hudi/pull/2248#discussion_r522372565



##########
File path: hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/SparkWriteHelper.java
##########
@@ -59,10 +59,9 @@ public static SparkWriteHelper newInstance() {
     }).reduceByKey((rec1, rec2) -> {
       @SuppressWarnings("unchecked")
       T reducedData = (T) rec1.getData().preCombine(rec2.getData());
-      // we cannot allow the user to change the key or partitionPath, since that will affect
-      // everything
-      // so pick it from one of the records.
-      return new HoodieRecord<T>(rec1.getKey(), reducedData);
+      HoodieKey reducedKey = rec1.getData().equals(reducedData) ? rec1.getKey() : rec2.getKey();
+
+      return new HoodieRecord<T>(reducedKey, reducedData);

Review comment:
       @wangxianghu Not necessarily. If global indexed it is reduced on record key not hoodie key. In the case I mentioned `rec1` and `rec2` would have different `partitionPath` values which is why arbitrarily choosing this causes an issue.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org