Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
## Bugfixes

* (Go) Fixed a data race on the Prism runner's artifact cache map in JobServices ([#32656](https://github.com/apache/beam/issues/32656)).
* (Java) Fixed the declared schema of the error output of the Kafka write SchemaTransform, which wrapped the error schema a second time and did not match the rows it emits ([#39760](https://github.com/apache/beam/issues/39760)).
* Fixed X (Java/Python) ([#X](https://github.com/apache/beam/issues/X)).

## Security Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,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 @@ -50,6 +50,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 @@ -280,6 +281,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