pankajbsn opened a new issue, #8103:
URL: https://github.com/apache/hudi/issues/8103

   1. I have a requirement where I need to combine fields from old and new 
records in OverwriteWithLatestAvroPayload.preCombine
   2. The default behaviour either selects old-record or `this` based on 
ordering Value.
   3. But in my case I need to combine fields from both old and new in same 
record before returning value.
   4. To be able to do this, I am trying to first convert 
`OverwriteWithLatestAvroPayload` to GenericRecord so that I can modify field 
values.
   5. In below code, if I return `newRec` as it is, it works as expected i.e. 
first  `preCombine` is called and then `combineAndGetUpdateValue` is called.
   6. But if I return newRec1 i.e. when I convert `GenericRecord` back to 
`OverwriteWithLatestAvroPayload` it doesn't work. I.e. `preCombine` is called 
but `combineAndGetUpdateValue` is not called.
   7. So the question is, how can I modify the record in preCombine before 
returning.
   
   ```java
       public OverwriteWithLatestAvroPayload 
preCombine(OverwriteWithLatestAvroPayload oldValue) {
           OverwriteWithLatestAvroPayload newRec = super.preCombine(oldValue);
   
           try {
               OverwriteWithLatestAvroPayload newRec1 = new 
OverwriteWithLatestAvroPayload(HoodieAvroUtils.bytesToAvro(newRec.recordBytes,defaultSchema),
 newRec.orderingVal);
               
System.out.println(HoodieAvroUtils.avroToJson(HoodieAvroUtils.bytesToAvro(newRec.recordBytes,defaultSchema),true));
               return newRec1;
           } catch (IOException e) {
               e.printStackTrace();
               return newRec;
           }
       }
   ```


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