hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java
/**
   * Adds the Hoodie metadata fields to the given schema.
   */
Adds the Hoodie metadata fields to the given schema.
Adds the Hoodie metadata fields to the given schema .
public static Schema addMetadataFields(Schema schema) {
    List<Schema.Field> parentFields = new ArrayList<>();
    Schema.Field commitTimeField =
        new Schema.Field(HoodieRecord.COMMIT_TIME_METADATA_FIELD, METADATA_FIELD_SCHEMA, "", JsonProperties.NULL_VALUE);
    Schema.Field commitSeqnoField =
        new Schema.Field(HoodieRecord.COMMIT_SEQNO_METADATA_FIELD, METADATA_FIELD_SCHEMA, "", JsonProperties.NULL_VALUE);
    Schema.Field recordKeyField =
        new Schema.Field(HoodieRecord.RECORD_KEY_METADATA_FIELD, METADATA_FIELD_SCHEMA, "", JsonProperties.NULL_VALUE);
    Schema.Field partitionPathField =
        new Schema.Field(HoodieRecord.PARTITION_PATH_METADATA_FIELD, METADATA_FIELD_SCHEMA, "", JsonProperties.NULL_VALUE);
    Schema.Field fileNameField =
        new Schema.Field(HoodieRecord.FILENAME_METADATA_FIELD, METADATA_FIELD_SCHEMA, "", JsonProperties.NULL_VALUE);
    parentFields.add(commitTimeField);
    parentFields.add(commitSeqnoField);
    parentFields.add(recordKeyField);
    parentFields.add(partitionPathField);
    parentFields.add(fileNameField);
    for (Schema.Field field : schema.getFields()) {
      if (!isMetadataField(field.name())) {
        Schema.Field newField = new Schema.Field(field.name(), field.schema(), field.doc(), field.defaultVal());
        for (Map.Entry<String, Object> prop : field.getObjectProps().entrySet()) {
          newField.addProp(prop.getKey(), prop.getValue());
        }
        parentFields.add(newField);
      }
    }
    Schema mergedSchema = Schema.createRecord(schema.getName(), schema.getDoc(), schema.getNamespace(), false);
    mergedSchema.setFields(parentFields);
    return mergedSchema;
  }
public static Schema addMetadataFields ( Schema schema ) { List < Schema . Field > parentFields = new ArrayList < > ( ) ; Schema . Field commitTimeField = new Schema . Field ( HoodieRecord . COMMIT_TIME_METADATA_FIELD , METADATA_FIELD_SCHEMA , "" , JsonProperties . NULL_VALUE ) ; Schema . Field commitSeqnoField = new Schema . Field ( HoodieRecord . COMMIT_SEQNO_METADATA_FIELD , METADATA_FIELD_SCHEMA , "" , JsonProperties . NULL_VALUE ) ; Schema . Field recordKeyField = new Schema . Field ( HoodieRecord . RECORD_KEY_METADATA_FIELD , METADATA_FIELD_SCHEMA , "" , JsonProperties . NULL_VALUE ) ; Schema . Field partitionPathField = new Schema . Field ( HoodieRecord . PARTITION_PATH_METADATA_FIELD , METADATA_FIELD_SCHEMA , "" , JsonProperties . NULL_VALUE ) ; Schema . Field fileNameField = new Schema . Field ( HoodieRecord . FILENAME_METADATA_FIELD , METADATA_FIELD_SCHEMA , "" , JsonProperties . NULL_VALUE ) ; parentFields . add ( commitTimeField ) ; parentFields . add ( commitSeqnoField ) ; parentFields . add ( recordKeyField ) ; parentFields . add ( partitionPathField ) ; parentFields . add ( fileNameField ) ; for ( Schema . Field field : schema . getFields ( ) ) { if ( ! isMetadataField ( field . name ( ) ) ) { Schema . Field newField = new Schema . Field ( field . name ( ) , field . schema ( ) , field . doc ( ) , field . defaultVal ( ) ) ; for ( Map . Entry < String , Object > prop : field . getObjectProps ( ) . entrySet ( ) ) { newField . addProp ( prop . getKey ( ) , prop . getValue ( ) ) ; } parentFields . add ( newField ) ; } } Schema mergedSchema = Schema . createRecord ( schema . getName ( ) , schema . getDoc ( ) , schema . getNamespace ( ) , false ) ; mergedSchema . setFields ( parentFields ) ; return mergedSchema ; }
Adds the Hoodie metadata fields to the given schema.
Adds the Hoodie metadata fields to the given schema .