FLATTEN

This page describes the FLATTEN function in Lenses SQL.

FLATTEN(array)

Flatten an array of arrays into an array.

Available in:

ProcessorsSQL Studio

Sample code:

USE `kafka`;
SELECT 
    FLATTEN(_value), 
    _value 
FROM products-array-test-2
LIMIT 1;

Output:

{
  "value": {
    "FLATTEN": [
      "128279ca-5f8d-44ef-b340-b8054a6611ec",
      6,
      "5ae063ba-0c94-4b9c-ad40-2da08ad8bfd2",
      8,
      "41bb7268-fa7c-426f-b549-4bb215579280",
      9,
      "35df5368-8b77-4081-9aab-96bc8de16c23",
      10,
      "da6d69ce-bbd9-4e56-861d-5018f2d9b23a",
      10,
      "c9725591-e6b6-4928-a6e8-7e37707965ec",
      2,
      "ac821f76-2ff0-4d0c-9540-b775f0602332",
      3,
      "f1f98a2c-e66e-44f3-bba1-58169a425862",
      1,
      "78ea76f1-7381-4b38-a25f-ee487bae9749",
      10,
      "5b84f92d-d8b8-4532-b452-639ab44ae017",
      5
    ]
  }
}
{
  "value": [
    [
      "128279ca-5f8d-44ef-b340-b8054a6611ec",
      6
    ],
    [
      "5ae063ba-0c94-4b9c-ad40-2da08ad8bfd2",
      8
    ],
    [
      "41bb7268-fa7c-426f-b549-4bb215579280",
      9
    ],
    [
      "35df5368-8b77-4081-9aab-96bc8de16c23",
      10
    ],
    [
      "da6d69ce-bbd9-4e56-861d-5018f2d9b23a",
      10
    ],
    [
      "c9725591-e6b6-4928-a6e8-7e37707965ec",
      2
    ],
    [
      "ac821f76-2ff0-4d0c-9540-b775f0602332",
      3
    ],
    [
      "f1f98a2c-e66e-44f3-bba1-58169a425862",
      1
    ],
    [
      "78ea76f1-7381-4b38-a25f-ee487bae9749",
      10
    ],
    [
      "5b84f92d-d8b8-4532-b452-639ab44ae017",
      5
    ]
  ]
}

Last updated

Logo

2024 © Lenses.io Ltd. Apache, Apache Kafka, Kafka and associated open source project names are trademarks of the Apache Software Foundation.