public static Target asTarget(Dataset dataset) {
Path directory = Accessor.getDefault().getDirectory(dataset);
if (directory != null) {
final Format format = dataset.getDescriptor().getFormat();
if (Formats.PARQUET.equals(format)) {
return new AvroParquetFileTarget(directory);
} else if (Formats.AVRO.equals(format)) {
return new AvroFileTarget(directory);
} else {
throw new UnsupportedOperationException(
"Not a supported format: " + format);