Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.ocient.com/llms.txt

Use this file to discover all available pages before exploring further.

Arrays, tuples, and matrix data types are complex data types in the System.

Arrays

The array data type is a one-dimensional list of values with the same data type. This type enables the support of a one-to-many relationship without creating another table. You create secondary indexes on arrays, which index the elements of the array. For details about secondary indexes, see Secondary Indexes. Key features:
  • Variable size.
  • Can contain many elements.
  • Indexing into the array starts at 1.
  • Invalid access of the array returns NULL.
For semi-structured data in JSON format, you can express the JSON multi-value column in an array data type. Traditionally in the normalized relational data model, the database represents such data types as a separate table. Each row stores the value of the primary key of the record in the parent table. Therefore, the entity relationship between the tables is always one-to-many, which can result in billions of rows. The array data type eliminates the child tables, which helps reduce the storage footprint and avoids the additional JOIN operations. Examples Create a one-dimensional integer array [1, 2, 3] using the sys.dummy virtual table.
SQL
 SELECT INT[](1,2,3)
 FROM sys.dummy1;
Output
Text
array_int(int((1)), int((2)), int((3)))
--------------------------------------------------------------------------------
[1,2,3]

Fetched 1 row
Create a two-dimensional integer array [[1, 2, 3], [4, 5, 6]].
SQL
 SELECT INT[][](INT[](1,2,3),INT[](4,5,6))
 FROM sys.dummy1;
Output
Text
array_array(int)(array_int(int((1)), int((2)), int((3))), array_int(int((4)), int((5)), int((6))))
---------------------------------------------------------------------------------------------------
[[1,2,3],[4,5,6]]

Fetched 1 row
You can get the same result by casting the array and integers explicitly.
SQL
SELECT INT[][](ARRAY[INT(1),INT(2),INT(3)],ARRAY[INT(4),INT(5),INT(6)])
FROM sys.dummy1;
For more examples, see Array Functions and Operators.

Tuples

The tuple data type is a row. This type is a fixed-sized collection of heterogeneous values. Tuples support more complex recursive computational functions. The memory structure of the tuple is identical to the memory structure of the array type. The only difference is that each entry in a tuple can be any type, so the Ocient System can simultaneously store both fixed and variable-sized values in a tuple. Examples Create a tuple with fixed-size types. In this case, use three integers.
SQL
SELECT TUPLE(1,2,3)
FROM sys.dummy1;
Output
Text
tuple((1), (2), (3))
--------------------------------------------------------------------------------
<<1, 2, 3>>

Fetched 1 row
You can get the same result by using the tuple type constructor.
SQL
SELECT TUPLE<<INT,INT,INT>>(1,2,3)
FROM sys.dummy1;
Create a tuple with variable-size types. In this case, use a one-dimensional and two-dimensional array.
SQL
SELECT TUPLE(ARRAY[INT(1),INT(2),INT(3)],
    INT[][](ARRAY[INT(1),INT(2),INT(3)],ARRAY[INT(4),INT(5),INT(6)]))
FROM sys.dummy1;
Output
Text
tuple(array_int(int((1)), int((2)), int((3))), array_array(int)(array_int(int((1)), int((2)), int((3))), array_int(int((4)), int((5)), int((6)))))
---------------------------------------------------------------------------------------------------------------------------------------------------
<<[1,2,3], [[1,2,3],[4,5,6]]>>

Fetched 1 row
Create a tuple with different types. In this case, an integer, string, and array of integers.
SQL
SELECT TUPLE<<INT,VARCHAR,INT[]>>(1, 'test_string', INT[](2,4,6))
FROM sys.dummy1;
Output
Text
tuple(int((1)), ('test_string'), array_int(int((2)), int((4)), int((6))))
--------------------------------------------------------------------------------
<<1, test_string, [2,4,6]>>

Fetched 1 row
For more examples, see Tuple Functions and Operators.

matrices

A matrix is a fixed-size two-dimensional array of DOUBLE values. A matrix can be a row vector (1xN matrix) or column vector (Nx1 matrix). matrices support machine learning model calculations. For details, see Machine Learning in Ocient. Examples Create a 1x4 matrix with numbers 1 through 4 using the make_matrix function that expects values in row-major order. The first two arguments indicate the dimensions of the matrix, and the remaining arguments specify the values for the matrix.
SQL
SELECT make_matrix_1x4(1,4,1,2,3,4)
FROM sys.dummy1;
Output
Text
make_matrix_1x4((1), (4), (1), (2), (3), (4))
--------------------------------------------------------------------------------
[[1.0,2.0,3.0,4.0]]

Fetched 1 row
Create a 2x3 matrix with numbers 1 through 6.
SQL
SELECT make_matrix_2x3(2,3,1,2,3,4,5,6)
FROM sys.dummy1;
Output
Text
make_matrix_2x3((2), (3), (1), (2), (3), (4), (5), (6))
--------------------------------------------------------------------------------
[[1.0,2.0,3.0],[4.0,5.0,6.0]]

Fetched 1 row
Create a row vector with four doubles.
SQL
SELECT _R{1,2,3,4}
FROM sys.dummy1;
Output
Text
_r{1,2,3,4}
--------------------------------------------------------------------------------
[[1.0,2.0,3.0,4.0]]

Fetched 1 row
For more examples, see Matrix Functions and Operators. Array Functions and Operators Tuple Functions and Operators Matrix Functions and Operators Generate Tables Using sys.dummy
Last modified on May 27, 2026