Skip to content

GetArrayItem returns incorrect results with dynamic index #3332

@andygrove

Description

@andygrove

Description

GetArrayItem (i.e., arr[idx] where idx is a column reference rather than a literal) returns results in incorrect order.

How to reproduce

CREATE TABLE test_get_array_item(arr array<int>, idx int) USING parquet;
INSERT INTO test_get_array_item VALUES (array(10, 20, 30), 0), (array(10, 20, 30), 1), (array(10, 20, 30), 2), (array(1), 0), (NULL, 0), (array(10, 20), NULL);
SELECT arr[idx] FROM test_get_array_item;

Expected results

[10]
[20]
[30]
[1]
[null]
[null]

Actual results

[10]
[10]
[1]
[20]
[30]
[null]

The results appear to be returned in an incorrect order.

Found via CometSqlFileTestSuite running expressions/array/get_array_item.sql.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions