当我运行 aerobic-forge-504:job_4_p6sq__0C5_3B-NVyVgg-Y2gf4
作业时,我收到了一条非常奇怪的错误消息
SELECT fullVisitorId as fullvisitorid,
date,
(visitStartTime+hits.time) as time,
first(customDimensions.value) over(partition by fullVisitorId)
FROM flatten([google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910] ,customDimensions)
where customDimensions.index=2
LIMIT 100
错误:Unrecognized 目前不支持作为分析函数。不确定这里出了什么问题。
我想返回 index=2 的第一个 customDimemsion
值及其首次记录的日期。由于 customDimension
和 hits
都是重复的字段,并且以某种方式分开,不确定这是否可能。
最佳答案
SQL 标准中分析函数的正确名称是 FIRST_VALUE。 FIRST 是 BigQuery 中的聚合函数。所以你的查询将是
SELECT fullVisitorId as fullvisitorid,
date,
(visitStartTime+hits.time) as time,
first_value(customDimensions.value) over(partition by fullVisitorId)
FROM flatten([google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910] ,customDimensions)
where customDimensions.index=2
LIMIT 100
更新回答问题
I want to return the first customDimemsion value for index=2 together with the date it was first recorded.
我会尝试使用 hits.customDimensions.[index|value],即
SELECT fullVisitorId, date, visitStartTime + first_hit_time, value FROM (
SELECT fullVisitorId,
date,
visitStartTime,
FIRST(hits.customDimensions.value) WITHIN hits as value,
FIRST(hits.time) WITHIN hits as first_hit_time
FROM
[google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
WHERE hits.customDimensions.index = 2)
关于google-bigquery - 第一个()函数 : Unrecognized is not currently supported as an analytic function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31400734/