我正在尝试将Bigquery中的分析数据展平,并且看到了同时打击点击和产品的其他答案,但是,当我包含unnest(product)时,我得到的结果就更少了,并且只收到hit.type行=“活动”。
如果我注释掉unnest(产品),那么我会收到更多的行,包括 hit.type ='PAGE'和 hit.type ='EVENT' 但后来我无法在选择中引用任何产品级别的数据,因为unnest(product)已被注释掉。
这仅在数据集的特定时期内发生,我在较早的数据中看到了PAGE匹配类型。我不明白!帮助!
可能会发生什么?
select
h.type as hits_type
-- ,product.productSKU
-- ,product.v2ProductName as product_name
from `bigquery-public-data.google_analytics_sample.ga_sessions_20170801`,
unnest(hits) h,
--unnest(h.product) as p
答案 0 :(得分:1)
我解决了自己的问题。
它需要左联接,因为我认为某些匹配不包含产品记录
from `bigquery-public-data.google_analytics_sample.ga_sessions_20170801` s, unnest(hits) h left join unnest(h.product) p