Skip to content

Array repeat, upcast issue #14228

@jatin510

Description

@jatin510

Describe the bug

In case of array_repeat, when the count variable is not of type Int64, it gives error.

In case of Int32, Int16, Int8, we should automatically convert it into Int64.

To Reproduce

select array_repeat(1 ,arrow_cast(2,'Int32'));

getting error:

Internal error: could not cast value to arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::Int64Type>.
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

Expected behavior

select array_repeat(1,2);
+---------------------------------+
| array_repeat(Int64(1),Int64(2)) |
+---------------------------------+
| [1, 1] |
+---------------------------------+
1 row(s) fetched.

Additional context

I think, for count variable we should upcast to Int64 if it is of type Int8, Int16, or Int32, preventing the error.

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