google-bigquery - 第一个()函数 : Unrecognized is not currently supported as an analytic function

标签 google-bigquery

当我运行 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 值及其首次记录的日期。由于 customDimensionhits 都是重复的字段,并且以某种方式分开,不确定这是否可能。

最佳答案

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/

相关文章:

mysql - 如何每天将联合表数据存储在历史表中 - Google BigQuery

sql - 如何将 SQL 中所有列中的 NULL 值更新为 0

google-bigquery - 字段不是叶字段

python - BigQuery 加载作业在来自 JSON 的 bool 数据类型字段上失败

sql - BigQuery 上的 WHERE 子句中的 SELECT 语句不起作用

sql - 如何按分区填充 BigQuery 中缺失的日期(无回填)

python - 将数据从 bigquery 转储到 postgresql

sql - 大写正则表达式替换 Google Bigquery 中的捕获组

google-bigquery - 通过自定义网页(不是内置的 WebUI)从 BigQuery 中提取数据

google-bigquery - BigQuery - 每个分区有多少条目?