@Override
    @SuppressWarnings("unchecked")
    public ClickHouseArraySequence setValue(int index, ClickHouseValue value) {
        try {
            getValue()[index] = (T) value.asRawObject();
            return this;
        } catch (ArrayStoreException arrayStoreException) {
            Class<?> existingArrayType = value.asRawObject().getClass();
            Class<?> idealArrayType = getValue().getClass();
            // Loop to find the root component type
            while (existingArrayType.isArray()) {
                existingArrayType = existingArrayType.getComponentType();
            }

            int idealCount = 0;
            while (idealArrayType.isArray()) {
                idealArrayType = idealArrayType.getComponentType();
                idealCount++;
            }

            // Create a new array of the correct type with the ideal depth
            Object newArray = Array.newInstance(existingArrayType, 1);
            for (int i = 1; i < idealCount - 1; i++) {
                newArray = Array.newInstance(newArray.getClass(), 1);
            }

            getValue()[index] = (T) newArray;
            return this;
        }
    }
Update value of the given object or create a new instance if {@code ref} is
null.

@param <T>   type of element
@param ref   object to update, could be null
@param value value
@return same object as {@code ref} or a new instance if it's null
clickhouse-data/src/main/java/com/clickhouse/data/value/ClickHouseArrayValue.java