Search code examples
postgresqlcube

Update/create postgres cube


Is it possible to update a single dimension for a cube?

I'd like to do something like this:

UPDATE mycubes a SET
    data=
    set_ur_dim_cube_bounds(4, cube_ur_coord(b.data, 4))
FROM
    myothercubes b
WHERE
    a.id = b.id;

EDIT w/ more info:

I installed the cube extension using create extension if not exists cube and the table was created with something along the lines of:

CRAETE TABLE mycubes (id serial primary key, data cube);

Solution

  • I think that simplest way for you will be get old value, change single dimension and update full cube value.

    data=
        cube(
            array[cube_ll_coord(a.data, 1), cube_ll_coord(a.data, 2),
                  cube_ll_coord(a.data, 3), cube_ll_coord(a.data, 4)],
            array[cube_ur_coord(a.data, 1), cube_ur_coord(a.data, 1),
                  cube_ur_coord(a.data, 3), cube_ur_coord(b.data, 4)]
        )