title: spark cogroup/join KeyValueGroupedDataset with Dataset
body: <p>I have 2 datasets.
  First has a number of rows with unique keys</p>
  <pre><code>ds1
  key   val1   val2
  1     a      1
  2     a      2
  3     b      3
  4     c      3
  </code></pre>
  <p>In the second same key can be encountered many times.</p>
  <pre><code>ds2
  key     val1     val2
  1       x        x    
  1       x        g    
  2       u        h    
  5       i        j    
                 
  </code></pre>
  <p>I need to join them, but the logic inside is too complicated for a simple join so instead I decided to use cogroup and iterate over the data.</p>
  <pre><code>val ds1 = df1.as[ds1].groupByKey(_.key)
  val ds2 = df2.as[ds2].groupByKey(_.key)
  
  ds2.cogroup(ds1)(
  (k:String, ds2:Iterator[ds2], ds1:Iterator[ds1]) =&gt; {
    //some logic
  }
  )
  </code></pre>
  <p>The problem is I don't actually need to group ds1, because I know it holds unique keys, but cogroup doesn't accept the ds overwise. I know there is the fullOuterJoin in the RDD class, but it has worse performance as far as I know.</p>
  <pre><code>val rdd1 = df1.as[ds1].rdd.map(x =&gt; (x.key, x))
  val rdd2 = df2.as[ds2].rdd.groupBy(_.key)
  
  rdd2.fullOuterJoin(rdd1)
  </code></pre>
  <p>Would it actually affect the performance? What alternatives are there if so?</p>
  <p>I'm using spark 2.2.</p>