> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Array Functions

<a id="sql-functions" />

<a id="sql-array-functions" />

<a id="sql-array-functions-scalar" />

## Scalar Functions

<AccordionGroup>
  <Accordion title="ARRAY_APPEND(array, value)" id="array_append-array-value" defaultOpen>
    Returns an array consisting of `array` with `value` appended to the end.
  </Accordion>

  <Accordion title="ARRAY_CONCAT(arr1, arr2)" id="array_concat-arr1-arr2" defaultOpen>
    Returns an array consisting of all the elements of array `arr1` followed by all of
    the elements of array `arr2`.
  </Accordion>

  <Accordion title="ARRAY_CONTAINS(array, value)" id="array_contains-array-value" defaultOpen>
    Returns true if `value` is present in `array`.
  </Accordion>

  <Accordion title="ARRAY_CONTAINS_ALL(arr1, arr2)" id="array_contains_all-arr1-arr2" defaultOpen>
    Returns true if every value in array `arr2` is present in array `arr1`; otherwise
    returns false.
  </Accordion>

  <Accordion title="ARRAY_CONTAINS_ANY(arr1, arr2)" id="array_contains_any-arr1-arr2" defaultOpen>
    Returns true if any value in array `arr2` is present in array `arr`; otherwise
    returns false.
  </Accordion>

  <Accordion title="ARRAY_DISTINCT(array)" id="array_distinct-array" defaultOpen>
    Returns an array consisting of `array` values with duplicates removed.
  </Accordion>

  <Accordion title="ARRAY_EMPTY(array)" id="array_empty-array" defaultOpen>
    Returns true if `array` is empty; otherwise returns false.
  </Accordion>

  <Accordion title="ARRAY_EXCEPT(arr1, arr2)" id="array_except-arr1-arr2" defaultOpen>
    Returns an array consisting of all of the elements of array `arr1` with the ones that
    also appear in array `arr2` removed.
  </Accordion>

  <Accordion title="ARRAY_INTERSECT(arr1, arr2)" id="array_intersect-arr1-arr2" defaultOpen>
    Returns an array consisting of all of the elements of array `arr1` that also appear
    in array `arr2`.
  </Accordion>

  <Accordion title="ARRAY_ITEM(array, pos)" id="array_item-array-pos" defaultOpen>
    Returns the item in `array` at the given 1-based `pos` position.

    See [examples](/content/concepts/array#array-func-ex-item).
  </Accordion>

  <Accordion title="ARRAY_LENGTH(array)" id="array_length-array" defaultOpen>
    Returns the number of items in the given `array` at the 1st dimension.

    See [examples](/content/concepts/array#array-func-ex-len).
  </Accordion>

  <Accordion title="ARRAY_LOWER(array, dim)" id="array_lower-array-dim" defaultOpen>
    Returns the lowest index of `array` in the given `dim` dimension; since all arrays
    are 1-dimensional, only specifying a dimension of `1` will return a value, and since
    array indices are 1-based, that value will always be `1`.
  </Accordion>

  <Accordion title="ARRAY_NDIMS(array)" id="array_ndims-array" defaultOpen>
    Returns the number of dimensions in the given `array`; since all arrays are
    1-dimensional, that number will always be `1`.
  </Accordion>

  <Accordion title="ARRAY_NOT_EMPTY(array)" id="array_not_empty-array" defaultOpen>
    Returns true if `array` is not empty; otherwise returns false.
  </Accordion>

  <Accordion title="ARRAY_SLICE(array, from, to)" id="array_slice-array-from-to" defaultOpen>
    Returns an array consisting of the values from `array` between the `from` index
    (inclusive) up to the `to` index (exclusive) using 0-based indexing. Negative indexes
    are treated as offsets from the end of the array.
  </Accordion>

  <Accordion title="ARRAY_TO_STRING(array, delim)" id="array_to_string-array-delim" defaultOpen>
    Converts the items of `array` into a string delimited by `delim`.

    See [examples](/content/concepts/array#array-func-ex-atos).
  </Accordion>

  <Accordion title="ARRAY_UPPER(array, dim)" id="array_upper-array-dim" defaultOpen>
    Returns the highest index of `array` in the given `dim` dimension; since all arrays
    are 1-dimensional, only specifying a dimension of `1` will return a value, and since
    array indices are 1-based, that value will always be equivalent to `ARRAY_LENGTH`.
  </Accordion>

  <Accordion title="MAKE_ARRAY(value)" id="make_array-value" defaultOpen>
    Returns an array consisting of the single `value` element.
  </Accordion>

  <Accordion title="STRING_TO_ARRAY(str, delim)" id="string_to_array-str-delim" defaultOpen>
    Converts the values in `str`, delimited by `delim`, into an array.

    See [examples](/content/concepts/array#array-func-ex-stoa).
  </Accordion>
</AccordionGroup>

<a id="sql-array-functions-agg" />

## Aggregation/Transposition Functions

The following functions can be used on [array](/content/concepts/array)
columns within [aggregations](/content/sql/query/aggregation#sql-aggregation).

These functions can be used to convert primitive column values into arrays of
those values (aggregation) or to convert array columns into columns of primitive
values (unnest).

<AccordionGroup>
  <Accordion title="ARRAY_AGG(expr)" id="array_agg-expr" defaultOpen>
    Combines column values within a group into a single *array* of those values.

    See [examples](/content/concepts/array#array-func-agg-ex-agg).
  </Accordion>

  <Accordion title="ARRAY_AGG_DISTINCT(expr)" id="array_agg_distinct-expr" defaultOpen>
    Combines column values within a group into a single *array* of those values, removing
    any duplicates.

    See [examples](/content/concepts/array#array-func-agg-ex-agg-dist).
  </Accordion>

  <Accordion title="UNNEST_JSON_ARRAY" id="unnest_json_array" defaultOpen>
    Transposes array values into columnar data.

    See [UNNEST\_JSON\_ARRAY](/content/concepts/array#array-func-unnest).
  </Accordion>
</AccordionGroup>
