title: register two udfs with the same name on sparkSession
body: <p>During migration form Spark 1.6 to Spark 2.2, I was faced with the problem.</p>
  
  <p>Implementation on Spark 1.6 has two UDFs:</p>
  
  <ul>
  <li><b>SparkSQL UDF</b> (implementation of org.apache.spark.sql.api.java.UDF2 registered via SQLContext.udf().register(…))</li>
  <li><b>Java custom UDFs designed for Hive</b> (implementation of org.apache.hadoop.hive.ql.udf.generic.GenericUDTF registered via HiveContext.sql(…))</li>
  </ul>
  
  <p>Both UDFs were registered via one context with the same name <i>foo</i></p>
  
  <p>example in java with a Spark 1.6: </p>
  
  <pre><code>public static void register(SQLContext sqlContext) {
   sqlContext.udf().register("foo", new Foo(), DataTypes.StringType);
   if (sqlContext instanceof HiveContext) {
    HiveContext hiveContext = (HiveContext) sqlContext;
    hiveContext.sql(
        "create temporary function foo as 'com.FooHive'");
   }
  }
  </code></pre>
  
  <p>I tried to do the same on SparkSession (Spark 2.2): </p>
  
  <pre><code>public static void register(SparkSession sparkSession) {
   sparkSession.udf().register("foo", new Foo(), DataTypes.StringType);
   sparkSession.sql(
        "create temporary function foo as 'com.FooHive'");
  }
  </code></pre>
  
  <p>This code causes Exception: </p>
  
  <pre><code>org.apache.spark.sql.AnalysisException: Function foo already exists;
  </code></pre>
  
  <p>Is there way to solve this issue on SparkSession?  </p>