title: Make spark return tuple (StructType) from case expression without UDFs
body: <p>I'm looking(did some tests without success) to return a tuple StructType from a case statement without using UDFs, is there any way to do it?</p>
  <p>Use case is: we have 2 columns that depend on the same conditions in a CASE expression so we see 2 options:</p>
  <ul>
  <li>writing the same conditions twice but returning different column (undesired)</li>
  <li>writing the conditions once but returning 2 values on every WHEN, this could be via a tuple that we then split.</li>
  </ul>
  <p>I know it can be done using a UDF but we avoid UDFs due to being treated as blackboxes by spark and hence they are not optimizable, so the question is: <strong>is there any way to make a CASE statement return multiple values without using UDFS?</strong></p>
  <p>Something similar to:</p>
  <pre><code>df = df.withColumn(&quot;tuple&quot;, expr(
  &quot;CASE WHEN &lt;condition 1&gt; THEN (value1,value2)
        WHEN &lt;condition 2&gt; THEN (value3,value4)
        ELSE (value5,value6)
  &quot;))
  
  df = df.withColumn(&quot;col1&quot;,col(&quot;tuple&quot;)[0])
  df = df.withColumn(&quot;col2&quot;,col(&quot;tuple&quot;)[1])
  </code></pre>