title: Hive: Create function if not exists
body: <p>At the start of my hive script i have the statement:</p>
  
  <p><code>create function x as y using jar z;</code></p>
  
  <p>Now, if the function already exists, it will give me an error:</p>
  
  <p><code>Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.FunctionTask. AlreadyExistsException(message:Function x already exists)</code></p>
  
  <p>If i use <code>create function if not exists x as y using jar z;</code>, i will get this error:</p>
  
  <p><code>Error while compiling statement: FAILED: ParseException line 7:192 cannot recognize input near 'if' 'not' 'exists' in function identifier</code></p>
  
  <p>The statement <code>create function if not exists</code> would work in Impala, but it seems that hive does not support it. Is that a way to do something similar in Hive?</p>