@Description("Reverse a given varbinary")
    @ScalarFunction("reverse")
    @SqlType(StandardTypes.VARBINARY)
    public static Slice reverse(@SqlType("varbinary") Slice inputSlice)
    {
        if (inputSlice.length() == 0) {
            return EMPTY_SLICE;
        }
        int length = inputSlice.length();
        Slice reverse = Slices.allocate(length);
        for (int i = 0; i < length; i++) {
            reverse.setByte(i, inputSlice.getByte((length - 1) - i));
        }
        return reverse;
    }
@Test
    public void testReverse()
    {
        assertFunction("REVERSE(CAST(null AS VARBINARY))", VARBINARY, null);
        assertFunction("REVERSE(CAST('' AS VARBINARY))", VARBINARY, sqlVarbinary(""));
        assertFunction("REVERSE(CAST('hello' AS VARBINARY))", VARBINARY, sqlVarbinary("olleh"));
        assertFunction("REVERSE(CAST('Quadratically' AS VARBINARY))", VARBINARY, sqlVarbinary("yllacitardauQ"));
        assertFunction("REVERSE(CAST('racecar' AS VARBINARY))", VARBINARY, sqlVarbinary("racecar"));
        assertFunction("REVERSE(REVERSE(CAST('hello' AS VARBINARY)))", VARBINARY, sqlVarbinary("hello"));
    }