Skip to content

Bug: Array Functions only return 1 element, and not working as expected #6709

Closed

Description

@parkma99

Describe the bug

As #6693 #6694 reported,array_length only return 1 element, and array_position not working as expected.
I test other array functions, finding some bugs.

array_ndims array_prepend array_remove only return 1 element, array_prepend array_remove also not working as exected.

array_dims array_position array_replace got DataFusion error

To Reproduce

In array.slt file, I add more tests for array function

statement ok
create table foo3 as values (['abc', 'bac']), (['ac']);

query I
select array_length(column1) from foo3;
----
2

query error DataFusion error: Arrow error: Invalid argument error: column types must match schema types, expected UInt8 but found List\(Field \{ name: "item", data_type: UInt8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: \{\} \}\) at column index 0
select array_dims(column1) from foo3;

query error DataFusion error: Internal error: Array_fill is not implemented for type 'Utf8'\.\. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
select array_fill('a', column1) from foo3;

query I
select array_ndims(column1) from foo3;
----
1

query error DataFusion error: Arrow error: Invalid argument error: column types must match schema types, expected UInt8 but found Null at column index 0
select array_position(column1, 'a') from foo3;

query ?
select array_prepend('a', column1) from foo3;
----
[a, a, abc, bac, ac]

query ?
select array_remove(column1, 'a') from foo3;
----
[abc, bac, ac]

query error DataFusion error: SQL error: ParserError\("Expected end of statement, found: \("\)
select select array_replace(column1,'a', 'a') from foo3;

The current expected result is not right result.

Expected behavior

No response

Additional context

No response

Activity

  1. bubbajoe commented on Jun 19, 2023

    @bubbajoe

    Thanks for testing! Should I close my tickets to avoid duplication?

  2. parkma99 commented on Jun 19, 2023

    @parkma99
    ContributorAuthor

    Thanks for testing! Should I close my tickets to avoid duplication?

    I think it's ok opening for track the array_length and array_position bugs.

  3. izveigor commented on Jun 29, 2023

    @izveigor
    Contributor

    @parkma99 the first implementation is only suitable for scalars. I will do for arrays soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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