Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) {
}

// TODO: include output from KafkaIO Write once updated from PDone
PCollection<Row> errorOutput =
outputTuple.get(ERROR_TAG).setRowSchema(ErrorHandling.errorSchema(errorSchema));
PCollection<Row> errorOutput = outputTuple.get(ERROR_TAG).setRowSchema(errorSchema);
return PCollectionRowTuple.of(
handleErrors ? configuration.getErrorHandling().getOutput() : "errors", errorOutput);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.beam.sdk.transforms.SerializableFunction;
import org.apache.beam.sdk.values.KV;
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.PCollectionRowTuple;
import org.apache.beam.sdk.values.PCollectionTuple;
import org.apache.beam.sdk.values.Row;
import org.apache.beam.sdk.values.TupleTag;
Expand Down Expand Up @@ -271,6 +272,29 @@ public void testBuildTransformWithManaged() {
}
}

@Test
public void testErrorOutputCarriesTheSchemaErrorCounterFnEmits() {
// The output schema is fixed while the graph is built, so this needs no runner.
p.enableAbandonedNodeEnforcement(false);

Schema inputSchema = Schema.builder().addByteArrayField("bytes").build();
KafkaWriteSchemaTransformProvider.KafkaWriteSchemaTransformConfiguration configuration =
KafkaWriteSchemaTransformProvider.KafkaWriteSchemaTransformConfiguration.builder()
.setFormat("RAW")
.setTopic("test-topic")
.setBootstrapServers("host:9092")
.setErrorHandling(ErrorHandling.builder().setOutput("errors").build())
.build();

PCollectionRowTuple output =
PCollectionRowTuple.of("input", p.apply(Create.empty(inputSchema)))
.apply(new KafkaWriteSchemaTransformProvider().from(configuration));

// ErrorCounterFn emits ErrorHandling.errorRecord(errorSchema, ...), where errorSchema is
// already ErrorHandling.errorSchema(inputSchema).
assertEquals(ErrorHandling.errorSchema(inputSchema), output.get("errors").getSchema());
}

@Test
public void testKafkaWriteSchemaTransformConfigurationSchema() throws NoSuchSchemaException {
Schema schema =
Expand Down
Loading