[
https://issues.apache.org/jira/browse/BEAM-4461?focusedWorklogId=205967&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-205967
]
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_r261341664
##########
File path:
sdks/java/core/src/test/java/org/apache/beam/sdk/schemas/transforms/CoGroupTest.java
##########
@@ -399,13 +387,307 @@ public void testMismatchingKeys() {
Create.of(Row.withSchema(CG_SCHEMA_1).addValues("user1", 9,
"us").build()))
.setRowSchema(CG_SCHEMA_1);
- TupleTag<Row> pc1Tag = new TupleTag<>("pc1");
- TupleTag<Row> pc2Tag = new TupleTag<>("pc2");
thrown.expect(IllegalStateException.class);
PCollection<KV<Row, Row>> joined =
- PCollectionTuple.of(pc1Tag, pc1)
- .and(pc2Tag, pc2)
- .apply("CoGroup", CoGroup.byFieldNames(pc1Tag,
"user").byFieldNames(pc2Tag, "count"));
+ PCollectionTuple.of("pc1", pc1, "pc2", pc2)
+ .apply(
+ "CoGroup",
+ CoGroup.join("pc1", By.fieldNames("user")).join("pc2",
By.fieldNames("count")));
+ pipeline.run();
+ }
+
+ private List<Row> innerJoin(
+ List<Row> inputs1,
+ List<Row> inputs2,
+ List<Row> inputs3,
+ String[] keys1,
+ String[] keys2,
+ String[] keys3,
+ Schema expectedSchema) {
+ List<Row> joined = Lists.newArrayList();
+ for (Row row1 : inputs1) {
+ for (Row row2 : inputs2) {
+ for (Row row3 : inputs3) {
+ boolean shouldJoin = true;
+ for (int i = 0; i < keys1.length && shouldJoin; ++i) {
+ shouldJoin =
+ Stream.of(row1.getValue(keys1[i]), row2.getValue(keys2[i]),
row3.getValue(keys3[i]))
+ .distinct()
+ .count()
+ == 1;
+ }
+ if (shouldJoin) {
+ joined.add(Row.withSchema(expectedSchema).addValues(row1, row2,
row3).build());
+ }
+ }
+ }
+ }
+ return joined;
+ }
+
Review comment:
In fact what actually happened was a NullPointerException :)
My thought is that we should fail in this case. Added a verification and a
test.
----------------------------------------------------------------
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: 205967)
Time Spent: 23h (was: 22h 50m)
> 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: 23h
> Remaining Estimate: 0h
>
> e.g. JoinBy(fields). Project, Filter, etc.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)