As a workaround I am currently using the following code to generate a
TableRow object from a Java Protobuf class - as I am facing a problem with
Beam schemas (
https://www.mail-archive.com/[email protected]/msg05799.html).

It relies on the TableRowJsonCoder:

      String json = JsonFormat.printer().omittingInsignificantWhitespace()
          .preservingProtoFieldNames().print(article.toBuilder());
      InputStream inputStream = new
ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8));

      TableRow tableRow = TableRowJsonCoder.of().decode(inputStream,
Coder.Context.OUTER);

However, the usage of Coder.Context is deprecated - I've tried to simply
use the decode(), but that defaults to Context.NESTED.

What is the correct way of doing this?

Best,
Tobi

Reply via email to