IdReplacerUDF extends EvalFunc<Tuple> { @Override public Schema outputSchema(Schema input) { try { return new Schema(new Schema.FieldSchema(getSchemaName(getClass().getName().toLowerCase().replace('.', '_'), input), getRecordSchema(input), DataType.TUPLE)); } catch (FrontendException ex) { return null; } }  @Override /** * UDF replaces original id with new id string. The input tuple should contain following elements: * a dot-separated list of field ids representing a path in the input tree structure (first element), * new id string (second element), the rest of the tuple should contain the consecutive fields of the input record. * * Replacing of multiple id fields is not implemented yet. Only one field replacing is implemented. * * @param tuple a tuple (id path - dot-separated list of fields indicating position in the record schema tree, new id string, input tuple fields...) * @return * @throws IOException */ Tuple exec(Tuple input); @Override Schema outputSchema(Schema input);  }
@Test public void testOutputSchema() throws Exception { Schema schema = new Schema(); schema.add(new FieldSchema(null, DataType.CHARARRAY)); schema.add(new FieldSchema(null, DataType.CHARARRAY)); FieldSchema idFieldSchema = new FieldSchema("id", DataType.CHARARRAY); schema.add(idFieldSchema); FieldSchema dedupFieldSchema = new FieldSchema("dedup", DataType.BOOLEAN); schema.add(dedupFieldSchema); Schema resultSchema = idReplacer.outputSchema(schema); assertNotNull(resultSchema); assertEquals(1, resultSchema.getFields().size()); assertEquals(idFieldSchema, resultSchema.getField(0).schema.getField(0)); assertEquals(dedupFieldSchema, resultSchema.getField(0).schema.getField(1)); }