Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/cube.sgml`
1aa4474c4f765911d913e1a38688dbf555a3fd13ae6cbb300000000100000fb0
 example, to get the first few cubes ordered by the first coordinate
   (lower left corner) ascending one could use the following query:
<programlisting>
SELECT c FROM test ORDER BY c ~&gt; 1 LIMIT 5;
</programlisting>
   And to get 2-D cubes ordered by the first coordinate of the upper right
   corner descending:
<programlisting>
SELECT c FROM test ORDER BY c ~&gt; 3 DESC LIMIT 5;
</programlisting>
  </para>

  <para>
   <xref linkend="cube-functions-table"/> shows the available functions.
  </para>

  <table id="cube-functions-table">
   <title>Cube Functions</title>
    <tgroup cols="1">
     <thead>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        Function
       </para>
       <para>
        Description
       </para>
       <para>
        Example(s)
       </para></entry>
      </row>
     </thead>

     <tbody>
      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>float8</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a one dimensional cube with both coordinates the same.
       </para>
       <para>
        <literal>cube(1)</literal>
        <returnvalue>(1)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>float8</type>, <type>float8</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a one dimensional cube.
       </para>
       <para>
        <literal>cube(1, 2)</literal>
        <returnvalue>(1),(2)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>float8[]</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a zero-volume cube using the coordinates defined by the array.
       </para>
       <para>
        <literal>cube(ARRAY[1,2,3])</literal>
        <returnvalue>(1, 2, 3)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>float8[]</type>, <type>float8[]</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a cube with upper right and lower left coordinates as defined by
        the two arrays, which must be of the same length.
       </para>
       <para>
        <literal>cube(ARRAY[1,2], ARRAY[3,4])</literal>
        <returnvalue>(1, 2),(3, 4)</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>cube</function> ( <type>cube</type>, <type>float8</type> )
        <returnvalue>cube</returnvalue>
       </para>
       <para>
        Makes a new cube by adding a dimension on to an existing cube,
        with the same values for both 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>

Title: Cube Functions and Constructors
Summary
The cube data type provides various functions and constructors for creating and manipulating cubes, including making one-dimensional cubes, zero-volume cubes, and adding dimensions to existing cubes. The functions allow for specifying coordinates, adding dimensions, and building cubes piece by piece from calculated values. The available functions include cube constructors that take float8 values, arrays of float8 values, and existing cube values, as well as a function to get the dimension of a cube.