1
具有索引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
。這怎麼能實現?
豈不內連接更快? – Dror
很可能不是 - 但你可以試試:)其間,你有沒有嘗試過?它爲你工作? –
它似乎在伎倆,但最終,我用了一種不同的方法。您的方法生成的數組不是我想要的。你的方法產生一個以會話爲中心的視圖,其中點擊被映射到數組。對? – Dror