Redshift, error in create a table with generated series

83 Views Asked by At

I'm trying to save a generated date series in a temporary table on redshit:

drop table if exists date_list;
create temporary table date_list as
with seq as(
select date '2020-02-27' + i as dt
from generate_series(1, (date '2020-12-01' - date '2020-02-27')) i
)
select * from seq;

But received the following error:

[Code: 500310, SQL State: 0A000]  [Amazon](500310) Invalid operation: Specified types or functions (one per INFO message) not supported on Redshift tables.;

I do not what part of the code caused this error since the syntax should be right.

1

There are 1 best solutions below

0
Bill Weiner On

Yes, generate_series() is a leader-node-only function and its results cannot be used on the compute nodes. The way to do this is with a recursive cte. See:

trying to create a date table in Redshift