@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    checkArgsSize(arguments, 2, 4);

    converters = new ObjectInspectorConverters.Converter[arguments.length];
    inputTypes = new PrimitiveObjectInspector.PrimitiveCategory[arguments.length];
    for (int i = 0; i < arguments.length; i++) {
      checkArgPrimitive(arguments, i);
      if (i < 2) {
        obtainStringConverter(arguments, i, inputTypes, converters);
      } else {
        obtainIntConverter(arguments, i, inputTypes, converters);
      }
    }

    if (arguments.length > 2 && arguments[2] instanceof ConstantObjectInspector) {
      posConst = getConstantIntValue(arguments, 2);
      isPosConst = true;
    }
    if (arguments.length > 3 && arguments[3] instanceof ConstantObjectInspector) {
      occurrenceConst = getConstantIntValue(arguments, 3);
      isOccurrenceConst = true;
      if (occurrenceConst != null && occurrenceConst <= 0) {
        throw new UDFArgumentException("occurrence of function INSTR should be " +
            "positive, got " + occurrenceConst);
      }
    }
    return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
  }
Generic UDF for string function <code>INSTR(str,substr[,pos[,occurrence]])</code>.
This extends the function from MySQL
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_instr
and mimics the function from Oracle
https://docs.oracle.com/database/121/SQLRF/functions089.htm#SQLRF00651

<pre>
usage:
INSTR(str, substr[, pos[, occurrence]])
</pre>
<p>
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFInstr.java