danny0405 commented on a change in pull request #4141:
URL: https://github.com/apache/hudi/pull/4141#discussion_r777805857



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/model/PartialUpdateWithLatestAvroPayload.java
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.common.model;
+
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.avro.HoodieAvroUtils.bytesToAvro;
+
+/**
+ * The only difference with {@link DefaultHoodieRecordPayload} is that support 
update partial fields
+ * in latest record which value is not null to existing record instead of all 
fields.
+ *
+ * <p> Assuming a {@link GenericRecord} has three fields: a int , b int, c 
int. The first record value: 1, 2, 3.
+ * The second record value is: 4, 5, null, the field c value is null. After 
call the combineAndGetUpdateValue method,
+ * we will get final record value: 4, 5, 3, field c value will not be 
overwritten because its value is null in latest record.
+ */

Review comment:
       ```java
   /**
    * The only difference with {@link 
OverwriteNonDefaultsWithLatestAvroPayload} is that it supports
    * merging the latest non-null partial fields with the old record instead of 
replacing the whole record.
    *
    * <p> Assuming a {@link GenericRecord} has row schema: (f0 int , f1 int, f2 
int).
    * The first record value is: (1, 2, 3), the second record value is: (4, 5, 
null) with the field c value as null.
    * Calling the #combineAndGetUpdateValue method of the two records returns 
record: (4, 5, 3).
    * Note that field c value is ignored because it is null.
    */
   ```

##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/model/PartialUpdateWithLatestAvroPayload.java
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.common.model;
+
+import org.apache.hudi.common.util.Option;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+
+import static org.apache.hudi.avro.HoodieAvroUtils.bytesToAvro;
+
+/**
+ * The only difference with {@link DefaultHoodieRecordPayload} is that support 
update partial fields
+ * in latest record which value is not null to existing record instead of all 
fields.
+ *
+ * <p> Assuming a {@link GenericRecord} has three fields: a int , b int, c 
int. The first record value: 1, 2, 3.
+ * The second record value is: 4, 5, null, the field c value is null. After 
call the combineAndGetUpdateValue method,
+ * we will get final record value: 4, 5, 3, field c value will not be 
overwritten because its value is null in latest record.
+ */
+public class PartialUpdateWithLatestAvroPayload extends 
DefaultHoodieRecordPayload {
+

Review comment:
       We can extend from `OverwriteNonDefaultsWithLatestAvroPayload` instead 
of `DefaultHoodieRecordPayload `, and we should override `#preCombine` instead 
of `combineAndGetUpdateValue `.




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