Github user roshannaik commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1914#discussion_r100959018
  
    --- Diff: docs/Joins.md ---
    @@ -0,0 +1,126 @@
    +---
    +title: Joining Streams in Storm Core
    +layout: documentation
    +documentation: true
    +---
    +
    +Storm core supports joining multiple data streams into one with the help 
of `JoinBolt`.
    +`JoinBolt` is a Windowed bolt, i.e. it waits for the configured window 
duration to match up the
    +tuples among the streams being joined. This helps align the streams within 
a Window boundary.
    +
    +Each of `JoinBolt`'s incoming data streams must be Fields Grouped on a 
single field. A stream 
    +should only be joined with the other streams using the field on which it 
has been FieldsGrouped.  
    +Knowing this will help understand the join syntax described below.  
    +
    +## Performing Joins
    +Consider the following SQL join involving 4 tables:
    +
    +```sql
    +select  userId, key4, key2, key3
    +from        table1
    +inner join  table2  on table2.userId =  table1.key1
    +inner join  table3  on table3.key3   =  table2.userId
    +left join   table4  on table4.key4   =  table3.key3
    +```
    +
    +Similar joins could be expressed on tuples generated by 4 spouts using 
`JoinBolt`:
    +
    +```java
    +JoinBolt jbolt =  new JoinBolt("spout1", "key1")                   // from 
       spout1  
    +                    .join     ("spout2", "userId",  "spout1")      // 
inner join  spout2  on spout2.userId = spout1.key1
    +                    .join     ("spout3", "key3",    "spout2")      // 
inner join  spout3  on spout3.key3   = spout2.userId   
    +                    .leftJoin ("spout4", "key4",    "spout3")      // left 
join   spout4  on spout4.key4   = spout3.key3
    +                    .select  ("userId, key4, key2, spout3:key3")   // 
chose output fields
    +                    .withTumblingWindow( new Duration(10, 
TimeUnit.MINUTES) ) ;
    +
    +topoBuilder.setBolt("joiner", jbolt, 1)
    +            .fieldsGrouping("spout1", new Fields("key1") )
    +            .fieldsGrouping("spout2", new Fields("userId") )
    +            .fieldsGrouping("spout3", new Fields("key3") )
    +            .fieldsGrouping("spout4", new Fields("key4") );
    +```
    +
    +The bolt constructor takes two arguments. The 1st argument introduces the 
data from `spout1`'
    +to be the first stream and specifies that it will always use field `key1` 
when joining this with the others streams.
    +The name of the component specified must refer to the spout or bolt that 
is directly connected to the Join bolt. 
    +Here data received from `spout1` must be fields grouped on `key1`. 
Similarly, each of the `leftJoin()` and `join()` method
    +calls introduce a new stream along with the field to use for the join. As 
seen in above example, the same FieldsGrouping
    +requirement applies to these streams as well. The 3rd argument to the join 
methods refers to another stream with which
    +to join.
    +
    +The `select()` method is used to specify the output fields. The argument 
to `select` is a comma separated list of fields.
    +Individual field names can be prefixed with a stream name to disambiguate 
between the same field name occurring in
    +multiple streams as follows:  `.select("spout3:key3, spout4:key3")`. 
Nested tuple types are supported if the
    --- End diff --
    
    ya... i started with the dot syntax... then realized that it still leaves 
ambiguity .. if there is a field and stream with same name. I wanted to avoid 
putting code to guess whether the first part is a stream name or a key name. So 
its just to avoid that corner case. 
    
    Standard SQL does not have this issue as it doesn't allow a mix of table 
names and nested field names in  a simple x.y.z format.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to