title: spark write: CSV data source does not support null data type
body: <p>I have an error in my code.  The code is dumping some data into Redshift database.</p>
  
  <p>After some investigation I found an easy way to reproduce it in spark console.</p>
  
  <p>This is working fine:</p>
  
  <pre><code>scala&gt; Seq("France", "Germany").toDF.agg(avg(lit(null))).write.csv("1.csv")
  scala&gt;
  </code></pre>
  
  <p>But if I replace <strong>avg</strong> with <strong>max</strong> I got an error "CSV data source does not support null data type."</p>
  
  <pre><code>scala&gt; Seq("France", "Germany").toDF.agg(max(lit(null))).write.csv("2.csv")
  java.lang.UnsupportedOperationException: CSV data source does not support null data type.
  </code></pre>
  
  <p>What's wrong with <strong>max</strong> ?</p>