Skip to content

Commit

Permalink
Simplifies BigQueryInsertError codification
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Alonso committed Jul 20, 2018
1 parent 8a6a8ea commit d1b13d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public void encode(BigQueryInsertError value, OutputStream outStream) throws IOE

TableRowJsonCoder.of().encode(value.getRow(), outStream);

String tableStrValue = MAPPER.writeValueAsString(value.getTable());
StringUtf8Coder.of().encode(tableStrValue, outStream);
StringUtf8Coder.of().encode(BigQueryHelpers.toTableSpec(value.getTable()), outStream);
}

@Override
Expand All @@ -54,8 +53,7 @@ public BigQueryInsertError decode(InputStream inStream) throws IOException {
MAPPER.readValue(
StringUtf8Coder.of().decode(inStream), TableDataInsertAllResponse.InsertErrors.class);
TableRow row = TableRowJsonCoder.of().decode(inStream);
TableReference ref =
MAPPER.readValue(StringUtf8Coder.of().decode(inStream), TableReference.class);
TableReference ref = BigQueryHelpers.parseTableSpec(StringUtf8Coder.of().decode(inStream));
return new BigQueryInsertError(row, err, ref);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public void testDecodeEncodeEqual() throws Exception {
.setMessage("A message")
.setDebugInfo("The debug info"))),
new TableReference()
.setProjectId("DummyProject")
.setDatasetId("DummyDataset")
.setTableId("table"));
.setProjectId("dummy-project-id")
.setDatasetId("dummy-dataset-id")
.setTableId("dummy-table-id"));

CoderProperties.coderDecodeEncodeEqual(TEST_CODER, value);
}
Expand Down

0 comments on commit d1b13d8

Please sign in to comment.