You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by John Smith <le...@gmail.com> on 2015/12/18 10:46:00 UTC

outputSchema

Hi,

I know that might be a trivial question, but im struggling here... I want
to define outputSchema to return one bag with two tuples. Below is a code
which apparently doesnt work and does something different ;-(

expected schema { tup1 (), tup2 () }

.... outputSchema(Schema input) ... {


            Schema sSet = new Schema();
            Schema nSet = new Schema();

            Schema outputTuple = new Schema();
            outputTuple.add(new Schema.FieldSchema("tup1", sSet,
DataType.TUPLE));

            Schema outputTuple2 = new Schema();
            outputTuple2.add(new Schema.FieldSchema("tup2", nSet,
DataType.TUPLE));

            //bag
            Schema outputBag = new Schema();
            outputBag.add(new Schema.FieldSchema(null, outputTuple,
DataType.BAG));
            outputBag.add(new Schema.FieldSchema(null, outputTuple2,
DataType.BAG));

            return new Schema(new
Schema.FieldSchema(getSchemaName(this.getClass().getName().toLowerCase(),
input),
                    outputBag, DataType.BAG));

}

thank you