SIZE function in Amazon QLDB - Amazon Quantum Ledger Database (Amazon QLDB)

SIZE function in Amazon QLDB

Important

End of support notice: Existing customers will be able to use Amazon QLDB until end of support on 07/31/2025. For more details, see Migrate an Amazon QLDB Ledger to Amazon Aurora PostgreSQL.

In Amazon QLDB, use the SIZE function to return 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