[
https://issues.apache.org/jira/browse/BEAM-10327?focusedWorklogId=452242&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-452242
]
ASF GitHub Bot logged work on BEAM-10327:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Jun/20 09:47
Start Date: 29/Jun/20 09:47
Worklog Time Spent: 10m
Work Description: rezarokni commented on a change in pull request #12097:
URL: https://github.com/apache/beam/pull/12097#discussion_r446764890
##########
File path:
examples/java/src/main/java/org/apache/beam/examples/snippets/Snippets.java
##########
@@ -914,4 +917,71 @@ public void process(ProcessContext c) {
return result;
}
}
+
+ public static class SchemaJoinPattern {
+ public static PCollection<String> main(
+ Pipeline p,
+ final List<Row> emailUsers,
+ final List<Row> phoneUsers,
+ Schema emailSchema,
+ Schema phoneSchema) {
+ // [START SchemaJoinPatternJoin]
+ // Create/Read Schema PCollections
+ PCollection<Row> emailList =
+ p.apply("CreateEmails",
Create.of(emailUsers).withRowSchema(emailSchema));
+
+ PCollection<Row> phoneList =
+ p.apply("CreatePhones",
Create.of(phoneUsers).withRowSchema(phoneSchema));
+
+ // Perform Join
+ PCollection<Row> resultRow =
+ emailList.apply("Apply Join", Join.<Row,
Row>innerJoin(phoneList).using("name"));
+
+ // Preview Result
+ resultRow.apply(
+ "Preview Result",
+ MapElements.into(TypeDescriptors.strings())
+ .via(
+ x -> {
+ System.out.println(x);
+ return "";
+ }));
+
+ /* Sample Output From the pipeline:
Review comment:
As this class is abstracted, the sample output can be difficult to tie
back as the data is not in this snippet but later on. Consider if inline will
be easier to follow for the example.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 452242)
Time Spent: 1h 10m (was: 1h)
> Patterns: Create a pattern showing use of Schema
> ------------------------------------------------
>
> Key: BEAM-10327
> URL: https://issues.apache.org/jira/browse/BEAM-10327
> Project: Beam
> Issue Type: New Feature
> Components: website
> Reporter: Abhishek Yadav
> Assignee: Abhishek Yadav
> Priority: P3
> Labels: pipeline-patterns
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> Currently the Documentation shows how we can perform a Join of PCollections
> using
> [CoGroupByKey|https://beam.apache.org/documentation/programming-guide/#cogroupbykey],
> but it requires a lot of boilerplate code, it would be nice to have a
> pattern that shows using Joins with the help of
> [Schemas|https://beam.apache.org/documentation/programming-guide/#what-is-a-schema].
--
This message was sent by Atlassian Jira
(v8.3.4#803005)