List Functions

This page lists the list (ListAccum) functions that are available in the GSQL query language.

head()

Syntax

head(list)

Description

head() returns the first element in a list. It is semantically the same as list.get(0)

Return type

ELEMENT

Parameters

Parameter

Description

Data type

list

A ListAccum parameter, where we want to retrieve the first element in the list

ListAccum<ELEMENT>

Example

head(["a", "b", "c"]) -> "a"

last()

Syntax

last(list)

Description

last() returns the last element in a list. It is semantically the same as list.get(list.size() - 1)

Return type

ELEMENT

Parameters

Parameter

Description

Data type

list

A ListAccum parameter, where we want to retrieve the last element in the list

ListAccum<ELEMENT>

Example

last(["a", "b", "c"]) -> "c"

range()

Syntax

range(start, end [, step])

Description

range() returns a ListAccum of integer values within a range bounded by a start value start and end value end, and an optional step size step. The range is inclusive, so the arithmetic progression will always contain start, and it may contain end.

Return type

ListAccum<INT>

Parameters

Parameter

Description

Data type

start

The starting value of the range

UINT, INT

end

The ending value of the range

UINT, INT

step

(Optional)

The difference between any two consecutive values in the range

UINT, INT

Example

range(0, 5) -> [0, 1, 2, 3, 4, 5]
range(5, 0, -1) -> [5, 4, 3, 2, 1, 0]
range(2, 18, 3) -> [2, 5, 8, 11, 14, 17]

size()

Syntax

size(list)

Description

size() returns the number of elements in a ListAccum

Return type

UINT

Parameters

Parameter

Description

Data type

list

A ListAccum parameter

ListAccum<ELEMENT>

Example

size(["a", "b", "c"]) -> 3

split()

Syntax

split(original, splitDelimiter)

Description

split() returns a list of strings resulting from the splitting of the original string on matches of the given delimiter.

Return type

ListAccum<STRING>

Parameters

Parameter

Description

Data type

original

The original string to split

STRING

splitDelimiter

The delimiter to split the original string on

STRING

Example

split("one,two", ",") -> ["one", "two"]
split("aaabcaabca", "abc") -> ["aa", "a", "a"]

tail()

Syntax

tail(list)

Description

tail() returns the copy of the list that includes all but the first element in the parameter list.

Return type

ListAccum<ELEMENT>

Parameters

Parameter

Description

Data type

list

A ListAccum parameter

ListAccum<ELEMENT>

Example

tail(["a", "b", "c"]) -> ["b", "c"]