title: Spark UDF error - Schema for type Any is not supported
body: <p>I’m trying to create a udf that will replace negative values in a column with 0.</p>
  
  <p>My dataframe is – called df, and contains one column called avg_x.
  This is my code for creating a udf </p>
  
  <pre><code>val noNegative = udf {(avg_acc_x: Double) =&gt; if(avg_acc_x &lt; 0) 0 else "avg_acc_x"}
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Schema for type Any is not supported
  </code></pre>
  
  <p>df.printSchema returns  </p>
  
  <pre><code>|-- avg_acc_x: double (nullable = false) 
  </code></pre>
  
  <p>so I don’t understand why this error is occurring?</p>