You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by re...@apache.org on 2019/04/25 19:10:44 UTC
[beam] branch master updated: Merge pull request #8385: Fix broken
parsing of uuid
This is an automated email from the ASF dual-hosted git repository.
reuvenlax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new b296dc9 Merge pull request #8385: Fix broken parsing of uuid
b296dc9 is described below
commit b296dc9e8b4a4330ab1189d667221e8d5095f866
Author: reuvenlax <re...@google.com>
AuthorDate: Thu Apr 25 12:10:34 2019 -0700
Merge pull request #8385: Fix broken parsing of uuid
---
.../core/construction/SchemaTranslation.java | 4 ++-
.../beam/sdk/transforms/ParDoSchemaTest.java | 39 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/SchemaTranslation.java b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/SchemaTranslation.java
index 3e0771c..86de2b8 100644
--- a/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/SchemaTranslation.java
+++ b/runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/SchemaTranslation.java
@@ -125,7 +125,9 @@ public class SchemaTranslation {
}
Schema schema = builder.build();
schema.setEncodingPositions(encodingLocationMap);
- schema.setUUID(UUID.fromString(protoSchema.getId()));
+ if (!protoSchema.getId().isEmpty()) {
+ schema.setUUID(UUID.fromString(protoSchema.getId()));
+ }
return schema;
}
diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoSchemaTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoSchemaTest.java
index 94f78e5..96ef3b63 100644
--- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoSchemaTest.java
+++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/ParDoSchemaTest.java
@@ -442,4 +442,43 @@ public class ParDoSchemaTest implements Serializable {
PAssert.that(output).containsInAnyOrder("a:1", "b:2", "c:3");
pipeline.run();
}
+
+ @DefaultSchema(JavaFieldSchema.class)
+ static class Nested {
+ final int field1;
+ final InferredPojo inner;
+
+ @SchemaCreate
+ public Nested(int field1, InferredPojo inner) {
+ this.field1 = field1;
+ this.inner = inner;
+ }
+ }
+
+ @Test
+ @Category({ValidatesRunner.class, UsesSchema.class})
+ public void testNestedSchema() {
+ List<Nested> pojoList =
+ Lists.newArrayList(
+ new Nested(1, new InferredPojo("a", 1)),
+ new Nested(2, new InferredPojo("b", 2)),
+ new Nested(3, new InferredPojo("c", 3)));
+
+ PCollection<String> output =
+ pipeline
+ .apply(Create.of(pojoList))
+ .apply(WithKeys.of("foo"))
+ .apply(Reshuffle.of())
+ .apply(Values.create())
+ .apply(
+ ParDo.of(
+ new DoFn<Nested, String>() {
+ @ProcessElement
+ public void process(@Element Nested nested, OutputReceiver<String> r) {
+ r.output(nested.inner.stringField + ":" + nested.inner.integerField);
+ }
+ }));
+ PAssert.that(output).containsInAnyOrder("a:1", "b:2", "c:3");
+ pipeline.run();
+ }
}