with flink version 1.12.0(versions before also affected)
I started a sql cli with a hive catalog and specified a user jar file with -j option like this:
when i tried to create a custom function using class from myfunc.jar，cli reported ClassNotFoundException.
me.aki.flink.flinkudf.MyFunc is the identifier of udf，which defined like this
after walking through the related code, I believe this is a bug caused by wrong classloader
when using a hive catalog, flink will use CatalogFunctionImpl to wrap the function。 The
isGeneric() methed uses Class.forName(String clazzName) which will use a current classloader(classloader loads flink/lib) to determine the class。
however with -j option, user jar is set to the ExecutionContext and loaded by another userClassLoader
and the fix can be easy to pass a classloader to the Class.forName method.
after do such fix and build a new flink dist，create function behaves right