【发布时间】:2014-06-06 09:32:36
【问题描述】:
我编写了一个 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);
}
谢谢。
【问题讨论】:
标签: hadoop apache-pig cloudera piggybak