Array Functions [Tech Preview]

On This Page
Tech Preview Note
The array functions are provided as a Tech Preview feature, which is included in the current release as a sneak peek to future release features but without official support in this release. Note that Tech Preview features don’t go through QA cycles and might result in unexpected behavior. Please consult the Iguazio support team before using these features.
Note
  • In v2.5.4, the array functions are supported in update expressions.

  • See also the array support of the max and min functions.

length

length(ARRAY)

Returns the length of the provided array or array slice (ARRAY) — i.e., the number of elements in the array or slice. The parameter can be the name of an array attribute (ARRAY-ATTRIBUTE), or a slice of an array attribute that indicates the zero-based index range of the array elements to compare (ARRAY-ATTRIBUTE[istart..iend]).

For example, for a myArray array attribute with the values 7, 13, 5, and 1, "length(myArray)" returns 4 and "length(myArray[2..3])" returns 2.

init_array

init_array(size, type)

Creates an array attribute and initializes all array elements to zero. The function receives the following parameters:

size
The size of the array — i.e., the number of elements in the array.

  • Type: Integer
  • Requirement: Required
type
The data type of the array elements.

  • Type: String
  • Requirement: Required
  • Valid Values: - 'int' — a 64-bit integer - 'double' — a 64-bit double

For example, an "arr = init_array(3, 'int')" update expression creates an arr array attribute that represents an integer array with three elements, all initialized to zero. You can also change the values of specific elements in the same expression — for example "arr=init_array(3, 'int'); arr[1]=1; arr[2]=arr[1]+1;" results in a new arr array attribute with three elements whose values are 0 (default), 1, and 2.

After creating an array attribute, you can use the array operator ([]) to reference array elements in update expressions.

See Also