Skip to content
Merged
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 @@ -39,18 +39,24 @@ public class JsonFileErrorsWrite extends FeatureStoreWrite {

@Override
public PDone expand(PCollection<FeatureRowExtended> input) {
return input.apply("Map to strings", MapElements.into(kvs(strings(), strings())).via(
(rowExtended) -> {
try {
return KV.of(
rowExtended.getRow().getEntityName(),
JsonFormat.printer().omittingInsignificantWhitespace()
.print(rowExtended)
);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}
)).apply("Write Error Json Files", new TextFileDynamicIO.Write(options, ".json"));
return input
.apply(
"Map to strings",
MapElements.into(kvs(strings(), strings()))
.via(
(rowExtended) -> {
try {
return KV.of(
rowExtended.getRow().getEntityName(),
JsonFormat.printer()
.omittingInsignificantWhitespace()
.print(rowExtended));
} catch (InvalidProtocolBufferException e) {
return KV.of(
rowExtended.getRow().getEntityName(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that rowExtended.getRow().getEntityName() was not the cause of the exception?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at worst, that line will return empty string.

e.toString());
}
}))
.apply("Write Error Json Files", new TextFileDynamicIO.Write(options, ".json"));
}
}