title: Registering UDF's dynamically using scala reflect not working
body: <p>I am registering my UDF's dynamically using scala reflect as shown below and this code works fine. However when I try to list spark functions using <code>spark.catalog</code> then I don't see it. Can you please help me understanding what I am missing here:</p>
  <pre><code>   spark.catalog.listFunctions().foreach{
        fun =&gt;
          if (fun.name == &quot;ModelIdToModelYear&quot;) {
            println(fun.name)
          }
      }
  </code></pre>
  <pre><code>def registerUDF(spark: SparkSession) : Unit = {
      val runtimeMirror = scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader)
      val moduleSymbol = runtimeMirror.moduleSymbol(Class.forName(&quot;com.local.practice.udf.UdfModelIdToModelYear&quot;))
      val targetMethod = moduleSymbol.typeSignature.members.filter{
        x =&gt; x.isMethod &amp;&amp; x.name.toString == &quot;ModelIdToModelYear&quot;
      }.head.asMethod
      val function = runtimeMirror.reflect(runtimeMirror.reflectModule(moduleSymbol).instance).reflectMethod(targetMethod)
      function(spark.udf)
    }
  </code></pre>
  <p>Below is my UDF definition</p>
  <pre><code>package com.local.practice.udf
  
  import org.apache.spark.sql.expressions.UserDefinedFunction
  import org.apache.spark.sql.functions.udf
  
  //noinspection ScalaStyle
  object UdfModelIdToModelYear {
  
    val ModelIdToModelYear: UserDefinedFunction = udf((model_id : String) =&gt; {
      val numPattern = &quot;(\\d{2})_.+&quot;.r
       numPattern.findFirstIn(model_id).getOrElse(&quot;0&quot;).toInt
    })
  
  }
  
  </code></pre>