[ 
https://issues.apache.org/jira/browse/BEAM-4461?focusedWorklogId=205959&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-205959
 ]

ASF GitHub Bot logged work on BEAM-4461:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 28/Feb/19 19:10
            Start Date: 28/Feb/19 19:10
    Worklog Time Spent: 10m 
      Work Description: reuvenlax commented on pull request #7353: [BEAM-4461] 
Support inner and outer style joins in CoGroup.
URL: https://github.com/apache/beam/pull/7353#discussion_r261341533
 
 

 ##########
 File path: 
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/CoGroup.java
 ##########
 @@ -107,156 +105,241 @@
  * those fields match. In this case, fields must be specified for every input 
PCollection. For
  * example:
  *
- * <pre>{@code PCollection<KV<Row, Row>> joined = PCollectionTuple
- *     .of(input1Tag, input1)
- *     .and(input2Tag, input2)
+ * <pre>{@code PCollection<KV<Row, Row>> joined
+ *      = PCollectionTuple.of("input1Tag", input1, "input2Tag", input2)
  *   .apply(CoGroup
- *     .byFieldNames(input1Tag, "referringUser"))
- *     .byFieldNames(input2Tag, "user"));
+ *     .join("input1Tag", By.fieldNames("referringUser")))
+ *     .join("input2Tag", By.fieldNames("user")));
  * }</pre>
+ *
+ * <p>Traditional (SQL) joins are cross-product joins. All rows that match the 
join condition are
+ * combined into individual rows and returned; in fact any SQL inner joins is 
a subset of the
+ * cross-product of two tables. This transform also supports the same 
functionality using the {@link
+ * Inner#crossProductJoin()} method.
+ *
+ * <p>For example, consider the SQL join: SELECT * FROM input1 INNER JOIN 
input2 ON input1.user =
+ * input2.user
+ *
+ * <p>You could express this with:
+ *
+ * <pre>{@code
+ * PCollection<Row> joined = PCollectionTuple.of("input1", input1, "input2", 
input2)
+ *   .apply(CoGroup.join(By.fieldNames("user")).crossProductJoin();
+ * }</pre>
+ *
+ * <p>The schema of the output PCollection contains a nested message for each 
of input1 and input2.
+ * Like above, you could use the {@link Convert} transform to convert it to 
the following POJO:
+ *
+ * <pre>{@code
+ * {@literal @}DefaultSchema(JavaFieldSchema.class)
+ * public class JoinedValue {
+ *  public Input1Type input1;
+ *  public Input2Type input2;
+ * }
+ * }</pre>
+ *
+ * <p>The {@link Unnest} transform can then be used to flatten all the 
subfields into one single
+ * top-level row containing all the fields in both Input1 and Input2; this 
will often be combined
+ * with a {@link Select} transform to select out the fields of interest, as 
the key fields will be
+ * identical between input1 and input2.
+ *
+ * <p>This transform also supports outer-join semantics. By default, all input 
PCollections must
+ * participate fully in the join, providing inner-join semantics. This means 
that if if all input
 
 Review comment:
   fixed
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 205959)
    Time Spent: 21h 40m  (was: 21.5h)

> Create a library of useful transforms that use schemas
> ------------------------------------------------------
>
>                 Key: BEAM-4461
>                 URL: https://issues.apache.org/jira/browse/BEAM-4461
>             Project: Beam
>          Issue Type: Sub-task
>          Components: sdk-java-core
>            Reporter: Reuven Lax
>            Assignee: Reuven Lax
>            Priority: Major
>              Labels: triaged
>          Time Spent: 21h 40m
>  Remaining Estimate: 0h
>
> e.g. JoinBy(fields). Project, Filter, etc.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to