Source:
public void prepareRun(BatchSinkContext context) throws IOException { config.validate(context.getInputSchema()); Job job = JobUtils.createInstance(); Configuration hConf = job.getConfiguration(); hConf.set(FileOutputFormat.OUTDIR, config.getOutputDir(context.getLogicalStartTime())); for (Map.Entry<String, String> entry : config.getFSProperties().entrySet()) { hConf.set(entry.getKey(), entry.getValue()); } Schema schema = config.getSchema(context.getInputSchema()); if (schema != null) { LineageRecorder lineageRecorder = new LineageRecorder(context, config.referenceName); lineageRecorder.createDataset(schema.toString()); } if ("text".equals(config.format)) { context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(TextOutputFormat.class, hConf))); } else if ("avro".equals(config.format)) { if (schema == null) { throw new IllegalStateException("Cannot write using avro format when schema is unknown. " + "Please set the schema explicitly."); } org.apache.avro.Schema avroSchema = new org.apache.avro.Schema.Parser().parse(schema.toString()); AvroJob.setOutputKeySchema(job, avroSchema); context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(AvroKeyOutputFormat.class, hConf))); } else if ("parquet".equals(config.format)) { if (schema == null) { throw new IllegalStateException("Cannot write using parquet format when schema is unknown. " + "Please set the schema explicitly."); } org.apache.avro.Schema avroSchema = new org.apache.avro.Schema.Parser().parse(schema.toString()); AvroParquetOutputFormat.setSchema(job, avroSchema); context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(AvroParquetOutputFormat.class, hConf))); } }

Target:
public void prepareRun(BatchSinkContext context) throws IOException { config.validate(context.getInputSchema()); Job job = JobUtils.createInstance(); Configuration hConf = job.getConfiguration(); hConf.set(FileOutputFormat.OUTDIR, config.getOutputDir(context.getLogicalStartTime())); for (Map.Entry<String, String> entry : config.getFSProperties().entrySet()) { hConf.set(entry.getKey(), entry.getValue()); } Schema schema = config.getSchema(context.getInputSchema()); LineageRecorder lineageRecorder = new LineageRecorder(context, config.referenceName); lineageRecorder.createExternalDataset(schema); if ("text".equals(config.format)) { context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(TextOutputFormat.class, hConf))); } else if ("avro".equals(config.format)) { if (schema == null) { throw new IllegalStateException("Cannot write using avro format when schema is unknown. " + "Please set the schema explicitly."); } org.apache.avro.Schema avroSchema = new org.apache.avro.Schema.Parser().parse(schema.toString()); AvroJob.setOutputKeySchema(job, avroSchema); context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(AvroKeyOutputFormat.class, hConf))); } else if ("parquet".equals(config.format)) { if (schema == null) { throw new IllegalStateException("Cannot write using parquet format when schema is unknown. " + "Please set the schema explicitly."); } org.apache.avro.Schema avroSchema = new org.apache.avro.Schema.Parser().parse(schema.toString()); AvroParquetOutputFormat.setSchema(job, avroSchema); context.addOutput(Output.of(config.referenceName, new SinkOutputFormatProvider(AvroParquetOutputFormat.class, hConf))); } }