selecting data from a view pointing to a redshift table having interleaved sort keys fails

0

Hi,

I have a table in Redshift that has the interleaved sort keys defined. I am trying to create a view in a different database (in the same cluster) pointing to this table and it does not allow me perform select on this view because the table has interleaved sort keys defined. If I switch the sort key to default (compound) then it works fine, but given the scenario I am in, interleaved sort key style works best. What is the reason view does not work with interleaved sort key and if there's any workaround?

Thanks

PS - The view creation is successful. Querying data after view is created fails because of the interleaved sort key

asked 9 months ago218 views
1 Answer
0

I just repro'd this on a dc2 cluster with the following and it worked fine:

create table customer_interleaved (
  c_custkey     	integer        not null,
  c_name        	varchar(25)    not null,
  c_address     	varchar(25)    not null,
  c_city        	varchar(10)    not null,
  c_nation      	varchar(15)    not null,
  c_region      	varchar(12)    not null,
  c_phone       	varchar(15)    not null,
  c_mktsegment      varchar(10)    not null)
diststyle all
interleaved sortkey (c_custkey, c_city, c_mktsegment);  

insert into customer_interleaved values
(1, 'a','b','c','d','e','f','g');

insert into customer_interleaved values
(2, 'h','i','j','k','l','m','n');

insert into customer_interleaved values
(3, 'o','p','q','r','s','t','u');

vacuum reindex customer_interleaved;

create view interleaver_view as select * from customer_interleaved;

select * from interleaver_view;

can you share the error you're getting when query'ing the view?

answered 9 months ago
  • Thanks for the inputs! The script you shared works fine when I create the view in same database. In my case, I have the table in db1 and view in db2 in the same cluster, view creation is successful, but when I try to select * from view, it gives me below error:

    SQL Error [XX000]: ERROR: Accessing relation 'customer_interleaved' with interleaved sort keys is not supported.

    The node type I am using is ra3.xlplus

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions