@Description("returns index of first occurrence of a substring (or 0 if not found)")
    @ScalarFunction("strpos")
    @LiteralParameters({"x", "y"})
    @SqlType(StandardTypes.BIGINT)
    public static long stringPosition(@SqlType("varchar(x)") Slice string, @SqlType("varchar(y)") Slice substring)
    {
        return stringPositionFromStart(string, substring, 1);
    }
@Test
    public void testStringPosition()
    {
        testStrPosAndPosition("high", "ig", 2L);
        testStrPosAndPosition("high", "igx", 0L);
        testStrPosAndPosition("Quadratically", "a", 3L);
        testStrPosAndPosition("foobar", "foobar", 1L);
        testStrPosAndPosition("foobar", "obar", 3L);
        testStrPosAndPosition("zoo!", "!", 4L);
        testStrPosAndPosition("x", "", 1L);
        testStrPosAndPosition("", "", 1L);

        testStrPosAndPosition("\u4FE1\u5FF5,\u7231,\u5E0C\u671B", "\u7231", 4L);
        testStrPosAndPosition("\u4FE1\u5FF5,\u7231,\u5E0C\u671B", "\u5E0C\u671B", 6L);
        testStrPosAndPosition("\u4FE1\u5FF5,\u7231,\u5E0C\u671B", "nice", 0L);

        testStrPosAndPosition(null, "", null);
        testStrPosAndPosition("", null, null);
        testStrPosAndPosition(null, null, null);

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