apache / apache/beam

Error occurred when transforming from row to a new row without setCoder

Open
#20,199 0 comments 0 reactions 0 assignees View on GitHub
bug core java P3
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

The output row from transform function uses the input row schema to verify which causes error. Ex:

```

.apply(MapElements.via(
new SimpleFunction() \{

@Override
public Row apply(Row line) {
return Row.withSchema(newSchema).addValues("a",
1, "b").build();
}
}));

```

Got error when the output row schema is not the same as the input row.

Need to add `.setCoder(RowCoder.of(newSchema))` after the transform function to make it work.

Related link: [https://stackoverflow.com/questions/61236972/beam-sql-udf-to-split-one-column-into-multiple-columns](https://stackoverflow.com/questions/61236972/beam-sql-udf-to-split-one-column-into-multiple-columns)

Imported from Jira [BEAM-9814](https://issues.apache.org/jira/browse/BEAM-9814). Original Jira may contain additional context.
Reported by: ruixuel.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.