SIZE function - Amazon Quantum Ledger Database (Amazon QLDB)

SIZE function

Returns the number of elements in a given container data type (list, structure, or bag).

Syntax

SIZE ( container )

Arguments

container

The container field name or expression that the function operates on.

Data types

Supported argument types:

  • list

  • structure

  • bag

Return type: int

If the input to SIZE is not a container, the function throws an error.

Examples

SIZE(`[]`) -- 0 SIZE(`[null]`) -- 1 SIZE(`[1,2,3]`) -- 3 SIZE(<<'foo', 'bar'>>) -- 2 SIZE(`{foo: bar}`) -- 1 (number of key-value pairs) SIZE(`[{foo: 1}, {foo: 2}]`) -- 2 SIZE(12) -- error -- Runnable statements SELECT SIZE(`[]`) FROM << 0 >> -- 0 SELECT SIZE(`[1,2,3]`) FROM << 0 >> -- 3

Related functions