Search in sources :

Example 1 with OverwriteWithLatestAvroPayload

use of org.apache.hudi.common.model.OverwriteWithLatestAvroPayload in project hudi by apache.

the class TestAWSDmsAvroPayload method testPreCombineWithDelete.

@Test
public void testPreCombineWithDelete() {
    Schema avroSchema = new Schema.Parser().parse(AVRO_SCHEMA_STRING);
    GenericRecord deleteRecord = new GenericData.Record(avroSchema);
    deleteRecord.put("field1", 4);
    deleteRecord.put("Op", "D");
    GenericRecord oldRecord = new GenericData.Record(avroSchema);
    oldRecord.put("field1", 4);
    oldRecord.put("Op", "I");
    AWSDmsAvroPayload payload = new AWSDmsAvroPayload(Option.of(deleteRecord));
    AWSDmsAvroPayload insertPayload = new AWSDmsAvroPayload(Option.of(oldRecord));
    try {
        OverwriteWithLatestAvroPayload output = payload.preCombine(insertPayload);
        Option<IndexedRecord> outputPayload = output.getInsertValue(avroSchema);
        // expect nothing to be committed to table
        assertFalse(outputPayload.isPresent());
    } catch (Exception e) {
        fail("Unexpected exception");
    }
}
Also used : OverwriteWithLatestAvroPayload(org.apache.hudi.common.model.OverwriteWithLatestAvroPayload) IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) GenericRecord(org.apache.avro.generic.GenericRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) Test(org.junit.jupiter.api.Test)

Aggregations

Schema (org.apache.avro.Schema)1 GenericRecord (org.apache.avro.generic.GenericRecord)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 OverwriteWithLatestAvroPayload (org.apache.hudi.common.model.OverwriteWithLatestAvroPayload)1 Test (org.junit.jupiter.api.Test)1