Program: 170094
Project: 170094
Buggy source:
int compute(String arg) throws Exception {
  ComputeConfig config=ConfigHelper.parseComputeConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  Dataset<GenericRecord> data=Datasets.load(config.uri);
  PCollection<GenericRecord> input=p.read(CrunchDatasets.asSource(data));
  RecordToExhibit rte=new RecordToExhibit(config.tempTables);
  ExhibitDescriptor descriptor=rte.getDescriptor(input.getPType());
  PCollection<Exhibit> exhibits=rte.apply(input);
  List<OutputGen> outputGens=Lists.newArrayList();
  Set<Schema> keySchemas=Sets.newHashSet();
  List<List<SchemaProvider>> providerLists=Lists.newArrayList();
  Set<Schema> interValueSchemas=Sets.newHashSet();
  List<Schema> outputSchemas=Lists.newArrayList();
  for (int i=0; i < config.outputTables.size(); i++) {
    OutputConfig output=config.outputTables.get(i);
    OutputGen gen=new OutputGen(i,output,descriptor);
    Schema keySchema=gen.getKeySchema();
    List<SchemaProvider> providers=gen.getSchemaProviders();
    List<Schema.Field> outputFields=Lists.newArrayList();
    for (    Schema.Field sf : keySchema.getFields()) {
      outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
    }
    for (    SchemaProvider sp : providers) {
      Schema s=sp.get(1);
      for (      Schema.Field sf : s.getFields()) {
        outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
      }
    }
    Schema outputSchema=Schema.createRecord("String_Node_Str" + i,"String_Node_Str","String_Node_Str",false);
    outputSchema.setFields(outputFields);
    System.out.println("String_Node_Str" + i + "String_Node_Str"+ outputSchema.toString(true));
    keySchemas.add(keySchema);
    interValueSchemas.addAll(Lists.transform(providers,new Function<SchemaProvider,Schema>(){
      @Nullable @Override public Schema apply(      SchemaProvider schemaProvider){
        return schemaProvider.get(0);
      }
    }
));
    outputGens.add(gen);
    outputSchemas.add(outputSchema);
    providerLists.add(providers);
  }
  Schema keySchema=unionKeySchema("String_Node_Str",Lists.newArrayList(keySchemas));
  Schema interValueSchema=unionValueSchema("String_Node_Str",Lists.newArrayList(interValueSchemas));
  SchemaProvider provider=new SchemaProvider(ImmutableList.of(keySchema,interValueSchema));
  AvroType<GenericData.Record> keyType=Avros.generics(keySchema);
  AvroType<GenericData.Record> interValueType=Avros.generics(interValueSchema);
  PTableType<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> ptt=Avros.tableOf(Avros.pairs(keyType,Avros.ints()),Avros.pairs(Avros.ints(),interValueType));
  PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> mapside=null;
  for (int i=0; i < outputGens.size(); i++) {
    PTable<GenericData.Record,Pair<Integer,GenericData.Record>> out=outputGens.get(i).apply(exhibits);
    PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> m=out.parallelDo(new SchemaMapFn(i,provider),ptt);
    mapside=(mapside == null) ? m : mapside.union(m);
  }
  GroupingOptions opts=GroupingOptions.builder().numReducers(config.parallelism).partitionerClass(JoinUtils.AvroIndexedRecordPartitioner.class).groupingComparatorClass(JoinUtils.AvroPairGroupingComparator.class).build();
  Schema outputUnionSchema=unionValueSchema("String_Node_Str",outputSchemas);
  PType<GenericData.Record> outputUnion=Avros.generics(outputUnionSchema);
  PTable<Integer,GenericData.Record> reduced=mapside.groupByKey(opts).combineValues(new ExCombiner(provider,keyType,interValueType,config.outputTables,providerLists)).parallelDo("String_Node_Str",new MergeRowsFn(config.outputTables,providerLists,outputUnionSchema),Avros.tableOf(Avros.ints(),outputUnion));
  for (int i=0; i < config.outputTables.size(); i++) {
    OutputConfig output=config.outputTables.get(i);
    AvroType<GenericData.Record> outType=Avros.generics(outputSchemas.get(i));
    PCollection<GenericData.Record> out=reduced.parallelDo(new FilterOutFn(i),outType);
    DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(outType.getSchema()).format(Formats.PARQUET).location(output.path).build();
    Datasets.create(output.uri,dd);
    out.write(new AvroParquetFileTarget(output.path),output.writeMode);
  }
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}

Fixed version (ground truth):
int compute(String arg) throws Exception {
  ComputeConfig config=ConfigHelper.parseComputeConfig(arg);
  Pipeline p=new MRPipeline(ExhibitTool.class,getConf());
  Dataset<GenericRecord> data=Datasets.load(config.uri);
  PCollection<GenericRecord> input=p.read(CrunchDatasets.asSource(data));
  RecordToExhibit rte=new RecordToExhibit(config.tempTables);
  ExhibitDescriptor descriptor=rte.getDescriptor(input.getPType());
  PCollection<Exhibit> exhibits=rte.apply(input);
  List<OutputGen> outputGens=Lists.newArrayList();
  Set<Schema> keySchemas=Sets.newHashSet();
  List<List<SchemaProvider>> providerLists=Lists.newArrayList();
  Set<Schema> interValueSchemas=Sets.newHashSet();
  List<Schema> outputSchemas=Lists.newArrayList();
  for (int i=0; i < config.outputTables.size(); i++) {
    OutputConfig output=config.outputTables.get(i);
    OutputGen gen=new OutputGen(i,output,descriptor);
    Schema keySchema=gen.getKeySchema();
    List<SchemaProvider> providers=gen.getSchemaProviders();
    List<Schema.Field> outputFields=Lists.newArrayList();
    for (    Schema.Field sf : keySchema.getFields()) {
      outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
    }
    for (    SchemaProvider sp : providers) {
      Schema s=sp.get(1);
      for (      Schema.Field sf : s.getFields()) {
        outputFields.add(new Schema.Field(sf.name(),sf.schema(),sf.doc(),sf.defaultValue()));
      }
    }
    Schema outputSchema=Schema.createRecord("String_Node_Str" + i,"String_Node_Str","String_Node_Str",false);
    outputSchema.setFields(outputFields);
    System.out.println("String_Node_Str" + i + "String_Node_Str"+ outputSchema.toString(true));
    keySchemas.add(keySchema);
    interValueSchemas.addAll(Lists.transform(providers,new Function<SchemaProvider,Schema>(){
      @Nullable @Override public Schema apply(      SchemaProvider schemaProvider){
        return schemaProvider.get(0);
      }
    }
));
    outputGens.add(gen);
    outputSchemas.add(outputSchema);
    providerLists.add(providers);
  }
  Schema keySchema=unionKeySchema("String_Node_Str",Lists.newArrayList(keySchemas));
  Schema interValueSchema=unionValueSchema("String_Node_Str",Lists.newArrayList(interValueSchemas));
  SchemaProvider provider=new SchemaProvider(ImmutableList.of(keySchema,interValueSchema));
  AvroType<GenericData.Record> keyType=Avros.generics(keySchema);
  AvroType<GenericData.Record> interValueType=Avros.generics(interValueSchema);
  PTableType<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> ptt=Avros.tableOf(Avros.pairs(keyType,Avros.ints()),Avros.pairs(Avros.ints(),interValueType));
  PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> mapside=null;
  for (int i=0; i < outputGens.size(); i++) {
    PTable<GenericData.Record,Pair<Integer,GenericData.Record>> out=outputGens.get(i).apply(exhibits);
    PTable<Pair<GenericData.Record,Integer>,Pair<Integer,GenericData.Record>> m=out.parallelDo(new SchemaMapFn(i,provider),ptt);
    mapside=(mapside == null) ? m : mapside.union(m);
  }
  GroupingOptions opts=GroupingOptions.builder().numReducers(config.parallelism).partitionerClass(JoinUtils.AvroIndexedRecordPartitioner.class).groupingComparatorClass(JoinUtils.AvroPairGroupingComparator.class).build();
  Schema outputUnionSchema=unionValueSchema("String_Node_Str",outputSchemas);
  PType<GenericData.Record> outputUnion=Avros.generics(outputUnionSchema);
  PTable<Integer,GenericData.Record> reduced=mapside.groupByKey(opts).combineValues(new ExCombiner(provider,keyType,interValueType,config.outputTables,providerLists)).parallelDo("String_Node_Str",new MergeRowsFn(config.outputTables,providerLists,outputUnionSchema),Avros.tableOf(Avros.ints(),outputUnion));
  for (int i=0; i < config.outputTables.size(); i++) {
    OutputConfig output=config.outputTables.get(i);
    AvroType<GenericData.Record> outType=Avros.generics(outputSchemas.get(i));
    PCollection<GenericData.Record> out=reduced.parallelDo(new FilterOutFn(i),outType);
    if (config.local) {
      out.write(To.textFile(output.path),output.writeMode);
    }
 else {
      DatasetDescriptor dd=new DatasetDescriptor.Builder().schema(outType.getSchema()).format(Formats.PARQUET).location(output.path).build();
      if (Datasets.exists(output.uri) && output.writeMode == Target.WriteMode.OVERWRITE) {
        Datasets.delete(output.uri);
      }
      Datasets.create(output.uri,dd);
      out.write(new AvroParquetFileTarget(output.path),output.writeMode);
    }
  }
  PipelineResult res=p.done();
  return res.succeeded() ? 0 : 1;
}