2016-08-05 90 views
11

我是Google BigQuery的新手。我需要查詢錯誤幫助:Google BigQuery中的錯誤<EOF>

"Encountered " "WITH" "with "" at line 1, column 1. Was expecting: EOF"

with 
    t1 as 
    (
    select 
    date(USEC_TO_TIMESTAMP(event_dim.timestamp_micros)) date, event_dim.name 
    from 
    [myfoody-1313:it_rawfish_myfoody_ANDROID.app_events_20160727] 
    where 
    event_dim.name='pv_detail' and event_dim.params.key='item_id' and 
    event_dim.params.value.string_value='31' 
) 
    select 
    date(d) as day, count(event_dim.name) 
from 
    generate_series(current_date - interval '6 day', current_date, '1 day') d 
    left join t1 on t1.date = d 
group by day 
order by day; 
+1

您使用以下米哈伊爾的建議,使標準的SQL後,您需要對您的查詢進行一些其他轉換,即: *使用'CAST(TIMESTAMP_MICROS(event_dim.timestamp_micros)AS DATE)'。 *使用顯式數組而不是'GENERATE_SERIES'。我提交了一個系列/數組生成的功能請求,可以填補這個空白:https://code.google.com/p/google-bigquery/issues/detail?id=646 –

+0

作爲更新,GENERATE_DATE_ARRAY是現在可用於BigQuery。在上面的查詢中,你可以使用'FROM UNNEST(GENERATE_DATE_ARRAY(DATE_SUB(CURRENT_DATE(),INTERVAL 6 DAY),CURRENT_DATE(),INTERVAL 1 DAY))AS D LEFT JOIN ...'。 –

回答

7

I need help on a query error: "Encountered " "WITH" "with "" at line 1, column 1. Was expecting: EOF"

與被支持的BigQuery標準SQL - 見Enabling Standard SQL - 你應該啓用標準SQL

+2

謝謝,API調用的默認值是「Legacy SQL」。這是噪音... – zhihong