

def _string_find(translator, expr):
    op = expr.op()
    (arg, substr, start, _) = op.args
    arg_formatted = translator.translate(arg)
    substr_formatted = translator.translate(substr)
    if (start and (not isinstance(start.op(), ir.Literal))):
        start_fmt = translator.translate(start)
        return 'locate({0}, {1}, {2} + 1) - 1'.format(substr_formatted, arg_formatted, start_fmt)
    elif (start and start.op().value):
        sval = start.op().value
        return 'locate({0}, {1}, {2}) - 1'.format(substr_formatted, arg_formatted, (sval + 1))
    else:
        return 'locate({0}, {1}) - 1'.format(substr_formatted, arg_formatted)

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py _string_find/original