【发布时间】:2017-10-06 10:04:06
【问题描述】:
索引为6 的customDimensions 对应于会话和命中级别的UUID。
在会话级别,我可以使用以下标准 SQL 查询来检索 UUID:
CREATE TEMP FUNCTION customDimensionByIndex(indx INT64, arr ARRAY<STRUCT<index INT64, value STRING>>) AS (
(SELECT x.value FROM UNNEST(arr) x WHERE indx=x.index)
);
SELECT
customDimensionByIndex(6, customDimensions) AS session_uuid -- Customer UUID
FROM `94860076.ga_sessions_20170822`
limit 10
同样,在我可以使用的点击级别上:
CREATE TEMP FUNCTION customDimensionByIndex(indx INT64, arr ARRAY<STRUCT<index INT64, value STRING>>) AS (
(SELECT x.value FROM UNNEST(arr) x WHERE indx=x.index)
);
SELECT
customDimensionByIndex(6, hits.customDimensions) AS hit_uuid -- Customer UUID
FROM `94860076.ga_sessions_20170822`, unnest(hits) as hits
limit 10
但是,我未能在同一个查询中同时使用两者。例如,我想要一个结果集,其中每一行对应一个会话,列是session_uuid 和array_of_hit_uuids。如何实现?
【问题讨论】:
标签: google-analytics google-bigquery