Skip to content

Internal error generate_series: Internal error: could not cast value to .....arrow_array::types::Date32Type` #11922

@alamb

Description

@alamb

Describe the bug

When running a query like

select generate_series(start, '1993-03-01', INTERVAL '1 year') from date_table;

You get an error:

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

To Reproduce

DataFusion CLI v40.0.0
> CREATE TABLE date_table(
  start DATE,
  stop DATE,
  step INTERVAL
) AS VALUES
  (DATE '1992-01-01', DATE '1993-01-02', INTERVAL '1' MONTH),
  (DATE '1993-02-01', DATE '1993-01-01', INTERVAL '-1' DAY),
  (DATE '1989-04-01', DATE '1993-03-01', INTERVAL '1' YEAR);
0 row(s) fetched.
Elapsed 0.016 seconds.

> select generate_series(start, '1993-03-01', INTERVAL '1 year') from date_table;

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

I expect you get the same answer as if you explicitly cast the second argument to date:

> select generate_series(start, '1993-03-01'::DATE, INTERVAL '1 year') from date_table;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| generate_series(date_table.start,Utf8("1993-03-01"),IntervalMonthDayNano("IntervalMonthDayNano { months: 12, days: 0, nanoseconds: 0 }")) |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| [1992-01-01, 1993-01-01]                                                                                                                  |
| [1993-02-01]                                                                                                                              |
| [1989-04-01, 1990-04-01, 1991-04-01, 1992-04-01]                                                                                          |
+-------------------------------------------------------------------------------------------------------------------------------------------+
3 row(s) fetched.
Elapsed 0.001 seconds.

Additional context

I added a test here: #11921

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