@Test public void testMetadataField() { GenericRecord rec = new GenericData.Record(new Schema.Parser().parse(EXAMPLE_SCHEMA)); rec.put("_row_key", "key1"); rec.put("non_pii_col", "val1"); rec.put("pii_col", "val2"); rec.put("timestamp", 3.5); GenericRecord rec1 = HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(SCHEMA_WITH_METADATA_FIELD)); assertNull(rec1.get("_hoodie_commit_time")); assertNull(rec1.get("nullable_field")); assertNull(rec1.get("nullable_field_wo_default")); }
public static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema) { return rewrite(record, getCombinedFieldsToWrite(record.getSchema(), newSchema), newSchema); }
HoodieAvroUtils { public static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema) { return rewrite(record, getCombinedFieldsToWrite(record.getSchema(), newSchema), newSchema); } }
HoodieAvroUtils { public static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema) { return rewrite(record, getCombinedFieldsToWrite(record.getSchema(), newSchema), newSchema); }  }
HoodieAvroUtils { public static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema) { return rewrite(record, getCombinedFieldsToWrite(record.getSchema(), newSchema), newSchema); }  static byte[] avroToBytes(GenericRecord record); static byte[] indexedRecordToBytes(T record); static byte[] avroToJson(GenericRecord record, boolean pretty); static GenericRecord bytesToAvro(byte[] bytes, Schema schema); static GenericRecord bytesToAvro(byte[] bytes, Schema writerSchema, Schema readerSchema); static GenericRecord jsonBytesToAvro(byte[] bytes, Schema schema); static boolean isMetadataField(String fieldName); static Schema createHoodieWriteSchema(Schema originalSchema); static Schema createHoodieWriteSchema(String originalSchema); static Schema addMetadataFields(Schema schema); static Schema removeMetadataFields(Schema schema); static String addMetadataColumnTypes(String hiveColumnTypes); static Schema getRecordKeySchema(); static Schema getRecordKeyPartitionPathSchema(); static GenericRecord addHoodieKeyToRecord(GenericRecord record, String recordKey, String partitionPath,
      String fileName); static Schema appendNullSchemaFields(Schema schema, List<String> newFieldNames); static GenericRecord addCommitMetadataToRecord(GenericRecord record, String instantTime, String commitSeqno); static GenericRecord stitchRecords(GenericRecord left, GenericRecord right, Schema stitchedSchema); static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema); static GenericRecord rewriteRecordWithOnlyNewSchemaFields(GenericRecord record, Schema newSchema); static byte[] compress(String text); static String decompress(byte[] bytes); static Schema generateProjectionSchema(Schema originalSchema, List<String> fieldNames); static String getNestedFieldValAsString(GenericRecord record, String fieldName, boolean returnNullIfNotFound); static Object getNestedFieldVal(GenericRecord record, String fieldName, boolean returnNullIfNotFound); static Schema getNullSchema(); static String sanitizeName(String name); }
HoodieAvroUtils { public static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema) { return rewrite(record, getCombinedFieldsToWrite(record.getSchema(), newSchema), newSchema); }  static byte[] avroToBytes(GenericRecord record); static byte[] indexedRecordToBytes(T record); static byte[] avroToJson(GenericRecord record, boolean pretty); static GenericRecord bytesToAvro(byte[] bytes, Schema schema); static GenericRecord bytesToAvro(byte[] bytes, Schema writerSchema, Schema readerSchema); static GenericRecord jsonBytesToAvro(byte[] bytes, Schema schema); static boolean isMetadataField(String fieldName); static Schema createHoodieWriteSchema(Schema originalSchema); static Schema createHoodieWriteSchema(String originalSchema); static Schema addMetadataFields(Schema schema); static Schema removeMetadataFields(Schema schema); static String addMetadataColumnTypes(String hiveColumnTypes); static Schema getRecordKeySchema(); static Schema getRecordKeyPartitionPathSchema(); static GenericRecord addHoodieKeyToRecord(GenericRecord record, String recordKey, String partitionPath,
      String fileName); static Schema appendNullSchemaFields(Schema schema, List<String> newFieldNames); static GenericRecord addCommitMetadataToRecord(GenericRecord record, String instantTime, String commitSeqno); static GenericRecord stitchRecords(GenericRecord left, GenericRecord right, Schema stitchedSchema); static GenericRecord rewriteRecord(GenericRecord record, Schema newSchema); static GenericRecord rewriteRecordWithOnlyNewSchemaFields(GenericRecord record, Schema newSchema); static byte[] compress(String text); static String decompress(byte[] bytes); static Schema generateProjectionSchema(Schema originalSchema, List<String> fieldNames); static String getNestedFieldValAsString(GenericRecord record, String fieldName, boolean returnNullIfNotFound); static Object getNestedFieldVal(GenericRecord record, String fieldName, boolean returnNullIfNotFound); static Schema getNullSchema(); static String sanitizeName(String name); static final Schema METADATA_FIELD_SCHEMA; static final Schema RECORD_KEY_SCHEMA; }