title: Error executing Apache BEAM sql query - Use a Window.into or Window.triggering transform prior to GroupByKey
body: <p><strong>How do I include Window.into or Window.triggering transform prior to GroupByKey in BEAM SQL?</strong></p>
  
  <p>I have following 2 tables:</p>
  
  <p>Ist table</p>
  
  <pre><code>CREATE TABLE table1(
  field1 varchar 
  ,field2 varchar
  )
  </code></pre>
  
  <p>2nd Table</p>
  
  <pre><code>CREATE TABLE table2(
  field1 varchar
  ,field3 varchar
  )
  </code></pre>
  
  <p>And I am writing the result in a 3rd Table</p>
  
  <pre><code>CREATE TABLE table3(
  field1 varchar
  ,field3 varchar
  )
  </code></pre>
  
  <p>First 2 tables are reading data from a kafka stream and I am doing a join on these tables and inserting the data into the third table, using the following query. The first 2 tables are un-bounded/non-bounded</p>
  
  <pre><code>INSERT INTO table3 
          (field1, 
           field3) 
  SELECT a.field1, 
     b.field3 
  FROM   table1 a 
     JOIN table2 b 
       ON a.field1 = b.field1 
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <blockquote>
    <p>Caused by: java.lang.IllegalStateException: GroupByKey cannot be
    applied to non-bounded PCollection in the GlobalWindow without a
    trigger. Use a Window.into or Window.triggering transform prior to
    GroupByKey.   at
    org.apache.beam.sdk.transforms.GroupByKey.applicableTo(GroupByKey.java:173)
      at
    org.apache.beam.sdk.transforms.GroupByKey.expand(GroupByKey.java:204)
      at
    org.apache.beam.sdk.transforms.GroupByKey.expand(GroupByKey.java:120)
      at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)    at
    org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:472)    at
    org.apache.beam.sdk.values.PCollection.apply(PCollection.java:286)    at
    org.apache.beam.sdk.transforms.join.CoGroupByKey.expand(CoGroupByKey.java:126)
      at
    org.apache.beam.sdk.transforms.join.CoGroupByKey.expand(CoGroupByKey.java:74)
      at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:537)    at
    org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:472)    at
    org.apache.beam.sdk.transforms.join.KeyedPCollectionTuple.apply(KeyedPCollectionTuple.java:107)
      at
    org.apache.beam.sdk.extensions.joinlibrary.Join.innerJoin(Join.java:59)
      at
    org.apache.beam.sdk.extensions.sql.impl.rel.BeamJoinRel.standardJoin(BeamJoinRel.java:217)
      at
    org.apache.beam.sdk.extensions.sql.impl.rel.BeamJoinRel.buildBeamPipeline(BeamJoinRel.java:161)
      at
    org.apache.beam.sdk.extensions.sql.impl.rel.BeamProjectRel.buildBeamPipeline(BeamProjectRel.java:68)
      at
    org.apache.beam.sdk.extensions.sql.impl.rel.BeamAggregationRel.buildBeamPipeline(BeamAggregationRel.java:80)
      at
    org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSinkRel.buildBeamPipeline(BeamIOSinkRel.java:64)
      at
    org.apache.beam.sdk.extensions.sql.impl.planner.BeamQueryPlanner.compileBeamPipeline(BeamQueryPlanner.java:127)
      at
    com.dss.tss.v2.client.BeamSqlCli.compilePipeline(BeamSqlCli.java:95)
      at com.dss.test.v2.client.SQLCli.main(SQLCli.java:100)</p>
  </blockquote>