Skip to content

Implement array_resize function #7194

Closed
@izveigor

Description

@izveigor

Is your feature request related to a problem or challenge?

Summary

Characteristic Description
Function name: array_resize
Aliases: list_resize
Original function?: No
Function Description: ClickHouse: Changes the length of the array.
DuckDB: Resizes the list to contain size elements. Initializes new elements with value or NULL if value is not set.
Sources: Concept DuckDB ClickHouse

Examples:

SELECT arrayResize([1], 3)

Query id: 2c975fce-0843-485f-9aef-1a8899728cdc

┌─arrayResize([1], 3)─┐
│ [1,0,0]             │
└─────────────────────┘
SELECT arrayResize([[1, 2]], 2)

Query id: 2765406e-c2dd-4208-bf5b-7fe42cd8b682

┌─arrayResize([[1, 2]], 2)─┐
│ [[1,2],[]]               │
└──────────────────────────┘
SELECT arrayResize([1, 2], 4, 5)

Query id: b75e55d1-1abb-4933-b2b1-f9d472308d91

┌─arrayResize([1, 2], 4, 5)─┐
│ [1,2,5,5]                 │
└───────────────────────────┘
SELECT arrayResize([[1, 2], [3, 4]], 4, [1, 1])

Query id: ebaeb0e6-b9e1-4a1f-986f-ff546eb37f9d

┌─arrayResize([[1, 2], [3, 4]], 4, [1, 1])─┐
│ [[1,2],[3,4],[1,1],[1,1]]                │
└──────────────────────────────────────────┘

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    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