Skip to content

Implement array_element function #6974

Closed
@izveigor

Description

@izveigor

Is your feature request related to a problem or challenge?

Summary

Characteristic Description
Function name: array_element
Aliases: array_extract, list_element, list_extract, array[i]
Original function?: No
Function Description: Clickhouse: Get the element with the index n from the array arr. n must be any integer type. Indexes in an array begin from one. Negative indexes are supported. In this case, it selects the corresponding element numbered from the end. For example, arr[-1] is the last item in the array. If the index falls outside of the bounds of an array, it returns some default value (0 for numbers, an empty string for strings, etc.), except for the case with a non-constant array and a constant index 0 (in this case there will be an error Array indices are 1-based).
DuckDB: Extract the indexth (1-based) value from the list.
Sources: Concept ClickHouse DuckDB

Examples:

select array_element([1, 2, 3, 4], 3);
----
3
select array_element([1, 2, 3, 4], 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