Skip to content

Implement array_split_into_chunks scalar function #16483

@allenshen13

Description

@allenshen13

Description

Description

Implement the following function:
array_split_into_chunks(array(T), int) -> array(array(T))
Returns an array of arrays splitting the input array into chunks of given length. The last chunk will be shorter than the chunk length if the array’s length is not an integer multiple of the chunk length. Ignores null inputs, but not elements.

SELECT array_split_into_chunks(ARRAY [1, 2, 3, 4], 3); – [[1, 2, 3], [4]] SELECT array_split_into_chunks(null, null); – null SELECT array_split_into_chunks(array[1, 2, 3, cast(null as int)], 2]); – [[1, 2], [3, null]]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions