title: Apache Spark: how to call UDF over dataset in Java?
body: <p>What is exact translation of below Scala code snippet in Java?</p>
  <pre><code>import org.apache.spark.sql.functions.udf 
  
  def upper(s:String) : String = {
      s.toUpperCase
  }
  val toUpper = udf(upper _)
  peopleDS.select(peopleDS(“name”), toUpper(peopledS(“name”))).show
  </code></pre>
  <p>Please fill below missing statement in Java:</p>
  <pre><code>import org.apache.spark.sql.api.java.UDF1;
  
  UDF1 toUpper = new UDF1&lt;String, String&gt;() {
      public String call(final String str) throws Exception {
          return str.toUpperCase();
      }
  };
  
  peopleDS.select(peopleDS.col(&quot;name&quot;), /* how to run  toUpper(&quot;name&quot;)) ? */.show();
  </code></pre>
  <hr />
  <h3>NOTE</h3>
  <p>Register UDF, then call using <code>selectExpr</code> works for me, but I need something similar to the showen above.</p>
  <p>Working example:</p>
  <pre><code>sqlContext.udf().register(
      &quot;toUpper&quot;,
      (String s) -&gt; s.toUpperCase(),
      DataTypes.StringType
  );
  peopleDF.selectExpr(&quot;toUpper(name)&quot;,&quot;name&quot;).show();
  </code></pre>