@Description("returns index of last occurrence of a substring (or 0 if not found)")
    @ScalarFunction("strrpos")
    @LiteralParameters({"x", "y"})
    @SqlType(StandardTypes.BIGINT)
    public static long stringReversePosition(@SqlType("varchar(x)") Slice string, @SqlType("varchar(y)") Slice substring)
    {
        return stringPositionFromEnd(string, substring, 1);
    }
@Test
    public void testStringReversePosition()
    {
        assertFunction("STRRPOS('high', 'ig')", BIGINT, 2L);
        assertFunction("STRRPOS('high', 'igx')", BIGINT, 0L);
        assertFunction("STRRPOS('Quadratically', 'a')", BIGINT, 10L);
        assertFunction("STRRPOS('foobar', 'foobar')", BIGINT, 1L);
        assertFunction("STRRPOS('foobar', 'obar')", BIGINT, 3L);
        assertFunction("STRRPOS('zoo!', '!')", BIGINT, 4L);
        assertFunction("STRRPOS('x', '')", BIGINT, 1L);
        assertFunction("STRRPOS('', '')", BIGINT, 1L);

        assertFunction("STRRPOS('\u4FE1\u5FF5,\u7231,\u5E0C\u671B', '\u7231')", BIGINT, 2L);
        assertFunction("STRRPOS('\u4FE1\u5FF5,\u7231,\u5E0C\u671B', '\u5E0C\u671B')", BIGINT, 3L);
        assertFunction("STRRPOS('\u4FE1\u5FF5,\u7231,\u5E0C\u671B', 'nice')", BIGINT, 0L);

        assertFunction("STRRPOS(NULL, '')", BIGINT, null);
        assertFunction("STRRPOS('', NULL)", BIGINT, null);
        assertFunction("STRRPOS(NULL, NULL)", BIGINT, null);

        assertFunction("STRRPOS('abc/xyz/foo/bar', '/')", BIGINT, 12L);
        assertFunction("STRRPOS('abc/xyz/foo/bar', '/', 1)", BIGINT, 12L);
        assertFunction("STRRPOS('abc/xyz/foo/bar', '/', 2)", BIGINT, 8L);
        assertFunction("STRRPOS('abc/xyz/foo/bar', '/', 3)", BIGINT, 4L);
        assertFunction("STRRPOS('abc/xyz/foo/bar', '/', 4)", BIGINT, 0L);
        assertFunction("STRRPOS('highhigh', 'ig', 1)", BIGINT, 6L);
        assertFunction("STRRPOS('highhigh', 'ig', 2)", BIGINT, 2L);
        assertFunction("STRRPOS('foobarfoo', 'fb', 1)", BIGINT, 0L);
        assertFunction("STRRPOS('foobarfoo', 'oo', 1)", BIGINT, 8L);
        // Assert invalid instance argument
        assertInvalidFunction("STRRPOS('abc/xyz/foo/bar', '/', 0)", "'instance' must be a positive number.");
        assertInvalidFunction("STRRPOS('', '', 0)", "'instance' must be a positive number.");
        assertInvalidFunction("STRRPOS('foobarfoo', 'obar', -1)", "'instance' must be a positive number.");
    }