title: In Spark, how can I split one DataFrame to two DataFrames?
body: <p>I have one big data of DataFrame A.</p>
  
  <p>I want to apply some filter to that and make a DataFrame B, and make another DataFrame C for not filtered data.</p>
  
  <p>In summary, it's similar to following pseudo code.</p>
  
  <pre class="lang-scala prettyprint-override"><code>A.foreach(_ =&gt; {
    if (isFiltered(_)) addToDF_B()
    else addToDF_C()
  })
  </code></pre>
  
  <p>And, B and C will be written to different tables.</p>
  
  <p>I tried to filter B firstly and use A.except(B) to make C, but it doesn't work if scheme has complex type(map or array).</p>
  
  <p>Except filtering twice, is any other way to do it at once?</p>
  
  <p>Thanks in advance.</p>