Redshift view with current_setting('timezone') error when filtering using sub-select

0

My team have their session timezones set differently, so to provide a consistent output, I thought I would utilise the following logic in views: convert_timezone(current_setting('timezone'),'Australia/Melbourne',<timestamp>) I have a view that also utilises the super datatype to simplify the extraction of data from json fields from a source system.

However testing a view prior to deployment, the following query with sub-select filter expressions fails:

create temp table test as
select * from <viewname>
where start_date between (select <date>) and (select <date>);

SQL Error [XX000]: ERROR: Query unsupported due to an internal error.

The following code illustrates the issue:

create or replace view sandpit.test as
select a.*, json_super."test" as test_val
from (
select convert_timezone('UTC','Australia/Melbourne',getdate()) as current_ts_AEST
    ,convert_timezone(current_setting('timezone'),'Australia/Melbourne',getdate()) as current_tz_AEST --comment out this line and both statements below succeed
    ,json_parse('{"test":1}') as json_super
) a
with no schema binding;

select * from sandpit.test where current_ts_AEST < getdate()::date + 1; --Works
select * from sandpit.test where current_ts_AEST < (select '2023-08-01'); --Fails with error
  • For anyone following this issue. AWS has confirmed it's an issue and Redshift engineering is working on a fix.

Zan
asked 10 months ago241 views
1 Answer
0

Hello,

To answer your question, we require details that are non-public information. Please open a support case with AWS using the following link with Redshift as the service and fill out the necessary template details.

https://docs.aws.amazon.com/awssupport/latest/user/case-management.html#creating-a-support-case

AWS
SUPPORT ENGINEER
answered 10 months ago
  • Thanks, I've raised case 13290408011

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