2016-03-04 57 views
1

我試圖運行下面的查詢做從紅移卸載到S3,並正在一個無用的錯誤。我們試圖逃避可能導致問題的所有字符,並傳遞參數(包裝程序是在Python):AWS卸載語句錯誤

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 

回答

2

您所需要的單詞「 as「前request_month