Arrays
This page describes examples of using arrays in Lenses SQL Studio to query Kafka.
Create an array field
You can create array fields using the ..[]
syntax:
CREATE TABLE table(
_key INT,
, fialdA INT[] -- Simple array
, fieldB.fieldC STRING[]) -- Array in a subfield
, fieldD INT[][] -- Nested array
FORMAT(avro, avro);
Select an array field
Tables can store data containing arrays. Here is a SQL statement for querying an array item:
SELECT
fieldA[1]
, fieldB.fieldC[2].x
FROM table
WHERE fieldA[1] LIKE '%Lenses%'
When working with arrays is good to check the array bounds. See the SIZEOF
function in the list of supported functions.
Query for array size
Sometimes you want to find out how many items are in your array. To do so you can run:
SELECT
SIZEOF(arrayFieldA)
FROM table
Last updated
Was this helpful?