Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/cube.sgml`
56c5ad53c792f31fbae6ea280ee0d99cdaf76a3ccfcf986d0000000100000fb0
 endpoints of the new coordinate.  This
        is useful for building cubes piece by piece from calculated values.
       </para>
       <para>
        <literal>cube('(1,2),(3,4)'::cube, 5)</literal>
        <returnvalue>(1, 2, 5),(3, 4, 5)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>cube</type>, <type>float8</type>, <type>float8</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a new cube by adding a dimension on to an existing cube. This is
        useful for building cubes piece by piece from calculated values.
       </para>
       <para>
        <literal>cube('(1,2),(3,4)'::cube, 5, 6)</literal>
        <returnvalue>(1, 2, 5),(3, 4, 6)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_dim</function> ( <type>cube</type> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Returns the number of dimensions of the cube.
       </para>
       <para>
        <literal>cube_dim('(1,2),(3,4)')</literal>
        <returnvalue>2</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_ll_coord</function> ( <type>cube</type>, <type>integer</type> )
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Returns the <parameter>n</parameter>-th coordinate value for the lower
        left corner of the cube.
       </para>
       <para>
        <literal>cube_ll_coord('(1,2),(3,4)', 2)</literal>
        <returnvalue>2</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_ur_coord</function> ( <type>cube</type>, <type>integer</type> )
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Returns the <parameter>n</parameter>-th coordinate value for the
        upper right corner of the cube.
       </para>
       <para>
        <literal>cube_ur_coord('(1,2),(3,4)', 2)</literal>
        <returnvalue>4</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_is_point</function> ( <type>cube</type> )
        <returnvalue>boolean</returnvalue>
       </para>
       <para>
        Returns true if the cube is a point, that is,
        the two defining corners are the same.
       </para>
       <para>
        <literal>cube_is_point(cube(1,1))</literal>
        <returnvalue>t</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_distance</function> ( <type>cube</type>, <type>cube</type> )
        <returnvalue>float8</returnvalue>
       </para>
       <para>
        Returns the distance between two cubes. If both
        cubes are points, this is the normal distance function.
       </para>
       <para>
        <literal>cube_distance('(1,2)', '(3,4)')</literal>
        <returnvalue>2.8284271247461903</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube_subset</function> ( <type>cube</type>, <type>integer[]</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a new cube from an existing cube, using a list of
        dimension indexes from an array. Can be used to extract the endpoints
        of a single dimension, or to drop dimensions, or to reorder them as
        desired.
       </para>
       <para>
        <literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2])</literal>
        <returnvalue>(3),(7)</returnvalue>
       </para>
       <para>
        <literal>cube_subset(cube('(1,3,5),(6,7,8)'),

Title: Cube Functions for Manipulation and Analysis
Summary
This section describes various functions for working with cubes, including functions to get the dimension of a cube, coordinates of the lower left and upper right corners, check if a cube is a point, calculate the distance between two cubes, and create a new cube by subset or reordering dimensions. These functions provide a range of tools for analyzing and manipulating cubes in different ways, such as extracting specific dimensions, reordering coordinates, and measuring distances.