Source:
private Schema getOutputSchema(Schema inputSchema, FailureCollector collector) { Schema output = schemaCache.get(inputSchema); if (output != null) { return output; } List<Schema.Field> outputFields = Lists.newArrayList(); for (Schema.Field inputField : inputSchema.getFields()) { String inputFieldName = inputField.getName(); if (fieldsToDrop.contains(inputFieldName)) { continue; } else if (!fieldsToKeep.isEmpty() && !fieldsToKeep.contains(inputFieldName)) { continue; } Schema outputFieldSchema = inputField.getSchema(); if (fieldsToConvert.containsKey(inputFieldName)) { outputFieldSchema = Schema.of(fieldsToConvert.get(inputFieldName)); Schema inputFieldSchema = inputField.getSchema(); Schema.Type inputFieldType = inputFieldSchema.getType(); if (inputFieldSchema.isNullable()) { inputFieldType = inputFieldSchema.getNonNullable().getType(); outputFieldSchema = Schema.nullableOf(outputFieldSchema); } if (!inputFieldType.isSimpleType() || inputFieldType == Schema.Type.NULL) { collector.addFailure( String.format("Field %s is of unconvertible type %s", inputFieldName, inputFieldType), null) .withConfigElement(CONVERT, String.format("%s:%s", inputFieldName, outputFieldSchema.getType().toString().toLowerCase())); collector.getOrThrowException(); } } String outputFieldName = inputFieldName; if (fieldsToRename.containsKey(inputFieldName)) { outputFieldName = fieldsToRename.get(inputFieldName); } outputFields.add(Schema.Field.of(outputFieldName, outputFieldSchema)); } output = Schema.recordOf(inputSchema.getRecordName() + ".projected", outputFields); schemaCache.put(inputSchema, output); return output; }

Target:
private Schema getOutputSchema(Schema inputSchema, FailureCollector collector) { Schema output = schemaCache.get(inputSchema); if (output != null) { return output; } List<Schema.Field> outputFields = Lists.newArrayList(); for (Schema.Field inputField : inputSchema.getFields()) { String inputFieldName = inputField.getName(); if (fieldsToDrop.contains(inputFieldName)) { continue; } else if (!fieldsToKeep.isEmpty() && !fieldsToKeep.contains(inputFieldName)) { continue; } Schema outputFieldSchema = inputField.getSchema(); if (fieldsToConvert.containsKey(inputFieldName)) { outputFieldSchema = Schema.of(fieldsToConvert.get(inputFieldName)); Schema inputFieldSchema = inputField.getSchema(); Schema.Type inputFieldType = inputFieldSchema.getType(); if (inputFieldSchema.isNullable()) { inputFieldType = inputFieldSchema.getNonNullable().getType(); outputFieldSchema = Schema.nullableOf(outputFieldSchema); } if (!inputFieldType.isSimpleType() || inputFieldType == Schema.Type.NULL) { String typeStr = outputFieldSchema.getType().toString().toLowerCase(); collector.addFailure( String.format("Field '%s' is of unconvertible type '%s'.", inputFieldName, inputFieldType), null) .withConfigElement(ProjectionTransformConfig.CONVERT, String.format("%s:%s", inputFieldName, typeStr)); collector.getOrThrowException(); } } String outputFieldName = inputFieldName; if (fieldsToRename.containsKey(inputFieldName)) { outputFieldName = fieldsToRename.get(inputFieldName); } outputFields.add(Schema.Field.of(outputFieldName, outputFieldSchema)); } output = Schema.recordOf(inputSchema.getRecordName() + ".projected", outputFields); schemaCache.put(inputSchema, output); return output; }