You can do this:

strLen = udf((s: String) => s.length())
cleanProcessDF.withColumn("dii",strLen(col("di")))

(You might need to play with the type signature a little bit to get it to
compile)


On Fri, Apr 10, 2015 at 11:30 AM, Yana Kadiyska <yana.kadiy...@gmail.com>
wrote:

> Hi, I'm running into some trouble trying to register a UDF:
>
> scala> sqlContext.udf.register("strLen", (s: String) => s.length())
> res22: org.apache.spark.sql.UserDefinedFunction = 
> UserDefinedFunction(<function1>,IntegerType)
>
> scala> cleanProcessDF.withColumn("dii",strLen(col("di")))
> <console>:33: error: not found: value strLen
>               cleanProcessDF.withColumn("dii",strLen(col("di")))
>
> ​
>
> Where cleanProcessDF is a dataframe
> Is my syntax wrong? Or am I missing an import of some sort?
>

Reply via email to