Search code examples
scalahadoopapache-sparkhiveudf

Hive UDF to process array of integers in Scala


I'm newbie in scala and I need to write user-defined function for processing columns with array of integers in Hive (type array<int>).

I've tried:

import org.apache.hadoop.hive.ql.exec.UDF

class testUDF extends UDF {

  def evaluate(arr: Array[Int], txt: String): Boolean = {
    return false
  }

}

But when I tried to call it in SQL I got error:

No matching method for class ... with (array<int>, string). Possible choices: _FUNC_(struct<>, string)

What type I need to use in Scala to work with array columns in Hive?


Solution

  • After some research I found specific class to that cases:

    import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;