Skip to content

GetArrayItem returns wrong results (off-by-one index) #3330

@andygrove

Description

@andygrove

Description

The get_array_item.sql SQL file test reveals incorrect results from the native GetArrayItem implementation.

Expected vs Actual

== Correct Answer ==      == Spark Answer ==
struct<arr[idx]:int>      struct<arr[idx]:int>
[10]                      [10]
[1]                       [10]   <-- wrong
[20]                      [1]
[30]                      [20]
[null]                    [30]
[null]                    [null]

The results are shifted — it appears the first row's value is duplicated and subsequent rows use the previous row's index. This suggests an off-by-one or stale-index bug in the native GetArrayItem evaluation.

Reproduction

Run CometSqlFileTestSuite — the get_array_item.sql test fails with both parquet.enable.dictionary=false and true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions