gpt4 book ai didi

python - AWS Unload 语句错误

转载 作者:行者123 更新时间:2023-12-01 04:04:52 26 4
gpt4 key购买 nike

我尝试运行以下查询以从 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

最佳答案

request_month 前需要有“as”一词

关于python - AWS Unload 语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35806441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com