I am new to Google BigQuery. I need help with the query error:
"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;
CAST(TIMESTAMP_MICROS(event_dim.timestamp_micros) AS DATE)
. * Use an explicit array instead ofGENERATE_SERIES
. I filed a feature request for series/array generation here, which would fill this gap: code.google.com/p/google-bigquery/issues/detail?id=646 – AlfredaGENERATE_DATE_ARRAY
is now available in BigQuery. in the query above, for instance, you could useFROM UNNEST(GENERATE_DATE_ARRAY(DATE_SUB(CURRENT_DATE(), INTERVAL 6 DAY), CURRENT_DATE(), INTERVAL 1 DAY)) AS d LEFT JOIN ...
. – Alfreda