Skip to content

Internal error with generate_series: Internal error: could not cast array of type Date32 #15881

@alamb

Description

@alamb

Describe the bug

When invalid arguments are passed to generate_series it generates internal errors rather than normal execution errorrs

Also the errors are not clear how to fix the issue

To Reproduce

> select generate_series(1, '2024-01-01', '2025-01-02');
Internal error: could not cast array of type Date32 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

Here is a similar one:

> select unnest(generate_series('2024-01-01'::timestamp, '2025-01-02', interval '1 day'));
Internal error: Unexpected argument type for GENERATE_SERIES : Date32.

Expected behavior

I think this should just be a normal error (not an internal error)

According to the docs, https://datafusion.apache.org/user-guide/sql/scalar_functions.html#generate-series the first and second argument must be the same

Arguments
start: Start of the series. Ints, timestamps, dates or string types that can be coerced to Date32 are supported.
end: End of the series (included). Type must be the same as start.
step: Increase by step (can not be 0). Steps less than a day are supported only for timestamp ranges.

Additional context

No response

Metadata

Metadata

Assignees

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