It looks like a regular Hive statement should work. In my script.sql which I run through spark-sql --jars mylib.jar myscript.sql
CREATE TEMPORARY FUNCTION rank AS 'com.mycompany.udf.Custom.rankFunc';
...
CREATE TEMPORARY VIEW MyTable AS (
SELECT
rank(id) AS rank,
...
In Scala code (mylib.jar):
package com.mycompany.udf
...
object Custom {
def rankFunc(id: Long): Double = { Rank(id).rank }
....
}
However, Hive code does not see this function.
18/01/23 17:38:25 ERROR SparkSQLDriver: Failed in [
CREATE TEMPORARY FUNCTION rank AS 'com.mycompany.udf.Custom.rankFunc']
java.lang.ClassNotFoundException: com.mycompany.udf.Custom.rankFunc
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
How should I change the code in my Scala library?

