1

I want to register a variable length function in spark sql with following code,

ssc.udf.register("md5", (a: String*) => {
  a.foldLeft(0)((x: Int, y: String) => x + y.length)
})

But it looks that it is not supported in this way,could someone help how to register a variable length function in spark sql, Thanks!

Tom
  • 5,848
  • 12
  • 44
  • 104
  • 3
    This is not possible, but there could be a workaround. Take a look at [this SO question](http://stackoverflow.com/questions/33151866/spark-udf-with-varargs) – Bhashit Parikh Nov 26 '16 at 05:28
  • Thanks @BhashitParikh – Tom Nov 26 '16 at 07:56
  • 2
    Possible duplicate of [Spark UDF with varargs](https://stackoverflow.com/questions/33151866/spark-udf-with-varargs). –  Nov 26 '16 at 09:48

0 Answers0