Skip to content

[FLINK-40357][table] Add ARRAY_FLATTEN function to Flink SQL - #28945

Open
cytq-123 wants to merge 9 commits into
apache:masterfrom
cytq-123:add-array-flatten-FLINK-40357
Open

[FLINK-40357][table] Add ARRAY_FLATTEN function to Flink SQL#28945
cytq-123 wants to merge 9 commits into
apache:masterfrom
cytq-123:add-array-flatten-FLINK-40357

Conversation

@cytq-123

@cytq-123 cytq-123 commented Aug 9, 2026

Copy link
Copy Markdown

What is the purpose of the change

This PR adds the ARRAY_FLATTEN function to Flink SQL, which flattens a nested array by one level.

Brief change log

  • Add ARRAY_FLATTEN function definition in BuiltInFunctionDefinitions
  • Implement ArrayFlattenFunction runtime class
  • Add type inference strategy in SpecificTypeStrategies
  • Add comprehensive test cases in CollectionFunctionsITCase

Verifying this change

This change added tests and can be verified as follows:

  • Added 10 test cases in CollectionFunctionsITCase#arrayFlattenTestCases()
  • Tests cover basic functionality, NULL handling, and edge cases

Does this pull request potentially affect one of the following parts:

  • Dependencies: no
  • The public API: no
  • The serializers: no
  • The runtime per-record code paths: no
  • Anything that affects deployment or recovery: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? JavaDocs

@flinkbot

flinkbot commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

"org.apache.flink.table.runtime.functions.scalar.ArrayConcatFunction")
.build();

public static final BuiltInFunctionDefinition ARRAY_FLATTEN =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please could you add documentation for this (Chinese and English)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Added documentation in:

  • docs/data/sql_functions.yml (English)
  • docs/data/sql_functions_zh.yml (Chinese)


private Stream<TestSetSpec> arrayFlattenTestCases() {
return Stream.of(
TestSetSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_FLATTEN)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you add error cases to the tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Added error validation test case for one-dimensional array input in CollectionFunctionsITCase.java:

  • testSqlValidationError for SQL API
  • testTableApiValidationError for Table API

- Add English and Chinese documentation in sql_functions.yml and sql_functions_zh.yml
- Add error validation test case for one-dimensional array input
- Address review feedback from davidradl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants