我正在尝试运行下面的查询来完成从Redshift到S3的卸载,并且得到了一个没有帮助的错误。我们已经尝试过转义可能导致问题的所有字符,并且正在传递参数(包装程序使用Python):
unload ('select
user_id
,course_id
,request_month
,user_agent_type
,count(session_id)
from
(select distinct
user_id
,context_id as course_id
,date_trunc(\'month\', request_timestamp) request_month
,session_id
,case
when user_agent like \'%CanvasAPI%\' then \'api\'
when user_agent like \'%candroid%\' then \'mobile_app_android\'
when user_agent like \'%iCanvas%\' then \'mobile_app_ios\'
when user_agent like \'%CanvasKit%\' then \'mobile_app_ios\'
when user_agent like \'%Windows NT%\' then \'desktop\'
when user_agent like \'%MacBook%\' then \'desktop\'
when user_agent like \'%iPhone%\' then \'mobile\'
when user_agent like \'%iPod Touch%\' then \'mobile\'
when user_agent like \'%iPad%\' then \'mobile\'
when user_agent like \'%iOS%\' then \'mobile\'
when user_agent like \'%CrOS%\' then \'desktop\'
when user_agent like \'%Android%\' then \'mobile\'
when user_agent like \'%Linux%\' then \'desktop\'
when user_agent like \'%Mac OS%\' then \'desktop\'
when user_agent like \'%Macintosh%\' then \'desktop\'
else \'other_unknown\'
end as user_agent_type
from {}
where context_type = \'Course\')
group by
user_id
,course_id
,request_month
,user_agent_type')
to {}
credentials 'aws_access_key_id={};aws_secret_access_key={}'
manifest
gzip
delimiter '|'错误如下:
2016-03-04 14:28:12,208 [CRITICAL] - Error occurred during transaction: syntax error at or near "month"
LINE 12: ,date_trunc('month', request_timestamp) request_month发布于 2016-03-04 21:44:40
您需要在request_month之前使用"as“这个词
https://stackoverflow.com/questions/35806441
复制相似问题