Shengyao He created FLINK-40357:
-----------------------------------

             Summary: Add ARRAY_FLATTEN function
                 Key: FLINK-40357
                 URL: https://issues.apache.org/jira/browse/FLINK-40357
             Project: Flink
          Issue Type: Improvement
          Components: Table SQL / API
            Reporter: Shengyao He


Add ARRAY_FLATTEN function to flatten nested arrays into a single array, 
similar to Snowflake, Redshift, and RisingWave.

h2. Syntax

{code:sql}
ARRAY_FLATTEN(array)
{code}

h2. Example

{code:sql}
SELECT ARRAY_FLATTEN(ARRAY[ARRAY[1, 2], ARRAY[3, 4]]);
-- Returns: [1, 2, 3, 4]

SELECT ARRAY_FLATTEN(ARRAY[ARRAY['a', 'b'], ARRAY['c']]);
-- Returns: ['a', 'b', 'c']
{code}

h2. Use Cases

- Processing nested JSON data
- Simplifying array aggregation results
- Data transformation pipelines

h2. Reference Implementations

- 
[Snowflake|https://docs.snowflake.com/en/sql-reference/functions/array_flatten]
- [AWS 
Redshift|https://docs.aws.amazon.com/redshift/latest/dg/array_flatten.html]
- [RisingWave|https://docs.risingwave.com/sql/functions/array]

I can contribute this implementation if approved.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to