It's messy. Easier to use the schema parser:
org.apache.pig.impl.util.Utils.getSchemaFromString("t:tuple(len:int,word:chararray)");Even easier to use the @OutputSchema annotation (coming in 0.11 I believe) -D On Wed, Apr 18, 2012 at 7:02 PM, Rajgopal Vaithiyanathan <[email protected]> wrote: > Hey all, > > Sorry if i sound naive, but how should one implement outputSchema of an > eval Func that returns tuple. > The way i do it is , > > public Schema outputSchema(Schema input) { > List<FieldSchema> list = new ArrayList<FieldSchema>(); > list.add(new FieldSchema("one", DataType.CHARARRAY)); > list.add(new FieldSchema("two", DataType.CHARARRAY)) > > return new Schema(list); > } > > but in the front end, If i use > B = foreach A generate flatten(FUNC()); > describe B > I get the schema like this: > { ( one:chararray, two:chararray ) } > Now i use a flatten on this like : > B = foreach A generate flatten(FUNC()); > and i get { null::one : chararray, null::two : chararray } > > The question is, > How should i implement the outputSchema so that i get the schema like { one > : chararray, two : chararray } // NOTE: without the parenthesis
