我刚开始使用Firebase-analytics来使用BigQuery,并尝试使用自定义参数从创建的事件中获取数据。
在第13行出现错误 UNNEST(user_dim.user_properties)user_properties 错误:无法识别的名称:user_dim;您是说user_id吗?
我尝试使用提到的代码。
SELECT
user_properties.value.value.string_value AS total_price,
AVG((
SELECT
SUM(value.string_value)
FROM
UNNEST(event_dim),
UNNEST(params)
WHERE
key = "quantity")) AS quantity
FROM
`uniorder-prod.analytics_200255431.events_*` t,
UNNEST(user_dim.user_properties) user_properties
WHERE
event_name = "total_consumption_res"
AND user_properties.key = "total_price"
我希望有2列,一列为total_price,另一列为数量,这将包含所有数量数据。
关于如何解决此问题的任何想法?
答案 0 :(得分:0)
您的查询似乎是针对旧数据库架构创建的,此后它已经被扁平化,因此您不再需要取消嵌套user_dim(或event_dim)来访问user_properties。
在此处签出新架构:https://support.google.com/firebase/answer/7029846?hl=en
答案 1 :(得分:0)
我做错了,所以如果您想得到结果,可以参考此答案。
//Query to run on BigQuery Console, you can change event param as per your
//need
SELECT
param2.value.string_value AS item_name,
SUM(param3.value.double_value) AS quantity,
SUM(param4.value.double_value) AS total_price
FROM
`uniorder-prod.analytics_200255431.events_*`,
UNNEST(event_params) AS param1,
UNNEST(event_params) AS param2,
UNNEST(event_params) AS param3,
UNNEST(event_params) AS param4
WHERE
event_name = "total_consumption_res"
AND param1.key = "user_id"
AND param1.value.int_value = 118
AND param2.key = "item_name"
AND param3.key = "quantity"
AND param4.key = "total_price"
GROUP BY
item_name
ORDER BY
total_price DESC