1
我已經寫了一個UDF,其中我的輸入模式是一袋元組,現在在我的UDF中,我正在處理每個元組併爲每個元組添加額外的字段並將其提供給輸出包。 這個效果很好,現在在我的下一步中,我嘗試創建輸出包的輸出模式,我想在我的包的輸入元組中添加一個字段。 我該怎麼做?如何將輸入模式添加到豬輸出中
這裏是我的輸入包架構。
xx: {(uniqueRS::PreprocUDF::id: long,uniqueRS::PreprocUDF::dominion: chararray,uniqueRS::PreprocUDF::affectedItemGRN: chararray,uniqueDomAndUser: {(PreprocUDF::dominion: chararray)},uniqueRS::PreprocUDF::count: long)}
現在我需要它這樣
outputBag: {(uniqueRS::PreprocUDF::id: long,uniqueRS::PreprocUDF::dominion: chararray,uniqueRS::PreprocUDF::affectedItemGRN: chararray,uniqueDomAndUser: {(PreprocUDF::dominion: chararray)},uniqueRS::PreprocUDF::count: long,grpName:chararray)}
我想這是我的輸出模式,但它並沒有奏效,
public Schema outputSchema(Schema input) {
Schema.FieldSchema grpName = new Schema.FieldSchema("grpName", DataType.CHARARRAY);
input.add(grpName);
retrun input;
}
我也`mergePrefixSchema嘗試()仍然沒有運氣,請幫助我。
這樣
public Schema outputSchema(Schema input) {
Schema.FieldSchema inputTupleFS = input.getField(0);
Schema.FieldSchema grpName = new Schema.FieldSchema("grpName", DataType.CHARARRAY);
ArrayList<Schema.FieldSchema> tupleList=new ArrayList();
tupleList.add(inputTupleFS);
tupleList.add(grpName);
Schema bagSchema =new Schema(tupleList);
Schema.FieldSchema bagFS =new Schema.FieldSchema("testBag", bagSchema, DataType.BAG);
Schema outputBag=new Schema(bagFS);
}
感謝也試過。