presto-main/src/main/java/io/prestosql/operator/scalar/ArrayElementAtFunction.java/ArrayElementAtFunction/checkedIndexToBlockPosition
class ArrayElementAtFunction:    private static int checkedIndexToBlockPosition(Block block, long index)
    {
        int arrayLength = block.getPositionCount();
        if (index == 0) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "SQL array indices start at 1");
        }
        if (Math.abs(index) > arrayLength) {
            return -1; // -1 indicates that the element is out of range and "ELEMENT_AT" should return null
        }
        if (index > 0) {
            return toIntExact(index - 1);
        }
        return toIntExact(arrayLength + index);
    }