public static Field newSchemaMetadataFieldBuilder ( String database , String tableName , LinkedHashMap < String , HiveTypeInfo > columnList , LinkedHashMap < String , HiveTypeInfo > partitionTypeList , boolean internal , String location , String avroSchema , HMPDataFormat dataFormat ) throws HiveStageCheckedException { LinkedHashMap < String , Field > metadata = new LinkedHashMap <> ( ) ; metadata . put ( VERSION , Field . create ( SCHEMA_CHANGE_METADATA_RECORD_VERSION ) ) ; metadata . put ( METADATA_RECORD_TYPE , Field . create ( MetadataRecordType . TABLE . name ( ) ) ) ; metadata . put ( DATABASE_FIELD , Field . create ( database ) ) ; metadata . put ( TABLE_FIELD , Field . create ( tableName ) ) ; metadata . put ( LOCATION_FIELD , Field . create ( location ) ) ; metadata . put ( DATA_FORMAT , Field . create ( dataFormat . name ( ) ) ) ; //fill in column type list here metadata . put ( COLUMNS_FIELD , generateInnerFieldFromTheList ( columnList , COLUMN_NAME , TYPE_INFO , true ) ) ; //fill in partition type list here if ( partitionTypeList != null && ! partitionTypeList . isEmpty ( ) ) { metadata . put ( PARTITION_FIELD , generateInnerFieldFromTheList ( partitionTypeList , PARTITION_NAME , TYPE_INFO , true ) ) ; } metadata . put ( INTERNAL_FIELD , Field . create ( internal ) ) ; metadata . put ( AVRO_SCHEMA , Field . create ( avroSchema ) ) ; return Field . createListMap ( metadata ) ; }
Fill in metadata to Record . This is for new schema creation .