Program: 170082
Project: 170082
Buggy source:
int build(String arg) throws Exception {
  BuildConfig config=parseBuildConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  List<PCollection<GenericRecord>> pcols=Lists.newArrayList();
  Set<Schema> schemas=Sets.newHashSet();
  for (  SourceConfig src : config.sources) {
    Dataset<GenericRecord> data=Datasets.load(src.uri);
    PCollection<GenericRecord> pcol=p.read(CrunchDatasets.asSource(data));
    pcols.add(pcol);
    Schema schema=((AvroType)pcol.getPType()).getSchema();
    src.setSchema(schema);
    schemas.add(schema);
  }
  Schema wrapper=unionValueSchema("String_Node_Str",schemas);
  AvroType<GenericData.Record> valueType=Avros.generics(wrapper);
  AvroType<Pair<Integer,GenericData.Record>> ssType=Avros.pairs(Avros.ints(),valueType);
  PType<Object> keyType=(PType<Object>)config.keyType.getPType();
  PTableType<Object,Pair<Integer,GenericData.Record>> tableType=Avros.tableOf(keyType,ssType);
  PTable<Object,Pair<Integer,GenericData.Record>> union=null;
  for (int i=0; i < config.sources.size(); i++) {
    SourceConfig src=config.sources.get(i);
    PCollection<GenericRecord> in=pcols.get(i);
    KeyIndexFn<GenericRecord> keyFn=new KeyIndexFn<GenericRecord>(valueType,src.keyFields,src.invalidKeys,i);
    PTable<Object,Pair<Integer,GenericData.Record>> keyed=in.parallelDo("String_Node_Str" + i,keyFn,tableType);
    if (union == null) {
      union=keyed;
    }
 else {
      union=union.union(keyed);
    }
  }
  MergeSchema ms=new MergeSchema(config.name,config.keyField,config.keyType.getSchema(),config.sources,config.parallelism);
  PCollection<GenericData.Record> output=ms.apply(union);
  DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(((AvroType)output.getPType()).getSchema()).format(Formats.PARQUET).build();
  Dataset<GenericRecord> outputDataset=Datasets.create(config.uri,dd);
  output.write(CrunchDatasets.asTarget(outputDataset),config.writeMode);
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}

Fixed version (ground truth):
int build(String arg) throws Exception {
  BuildConfig config=parseBuildConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  List<PCollection<GenericRecord>> pcols=Lists.newArrayList();
  Set<Schema> schemas=Sets.newHashSet();
  for (  SourceConfig src : config.sources) {
    Dataset<GenericRecord> data=Datasets.load(src.uri);
    PCollection<GenericRecord> pcol=p.read(CrunchDatasets.asSource(data));
    pcols.add(pcol);
    Schema schema=((AvroType)pcol.getPType()).getSchema();
    src.setSchema(schema);
    schemas.add(schema);
  }
  Schema wrapper=unionValueSchema("String_Node_Str",Lists.newArrayList(schemas));
  AvroType<GenericData.Record> valueType=Avros.generics(wrapper);
  AvroType<Pair<Integer,GenericData.Record>> ssType=Avros.pairs(Avros.ints(),valueType);
  PType<Object> keyType=(PType<Object>)config.keyType.getPType();
  PTableType<Object,Pair<Integer,GenericData.Record>> tableType=Avros.tableOf(keyType,ssType);
  PTable<Object,Pair<Integer,GenericData.Record>> union=null;
  for (int i=0; i < config.sources.size(); i++) {
    SourceConfig src=config.sources.get(i);
    PCollection<GenericRecord> in=pcols.get(i);
    KeyIndexFn<GenericRecord> keyFn=new KeyIndexFn<GenericRecord>(valueType,src.keyFields,src.invalidKeys,i);
    PTable<Object,Pair<Integer,GenericData.Record>> keyed=in.parallelDo("String_Node_Str" + i,keyFn,tableType);
    if (union == null) {
      union=keyed;
    }
 else {
      union=union.union(keyed);
    }
  }
  MergeSchema ms=new MergeSchema(config.name,config.keyField,config.keyType.getSchema(),config.sources,config.parallelism);
  PCollection<GenericData.Record> output=ms.apply(union);
  DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(((AvroType)output.getPType()).getSchema()).format(Formats.PARQUET).build();
  Dataset<GenericRecord> outputDataset=Datasets.create(config.uri,dd);
  output.write(CrunchDatasets.asTarget(outputDataset),config.writeMode);
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}