我试图创建一个允许我看到firebse_event_origin =“auto”和firebase_screen_class = TicketViewController的次数的查询。
我尝试使用AND语句,如下图所示,但我没有得到任何结果。 (ps。有些情况会发生)。
https://i.stack.imgur.com/XyX2R.png
基本上我想要知道的是:
当firebase_event_origin =“auto”时发生了多少次screen_view事件
firebase_screen_class =“TicketViewController”
答案 0 :(得分:2)
这可能是您正在寻找的,或者可能会给您一些见解:
SELECT
count(1) screen_views
FROM `ruter-pilot.no_ruter_RuterPilot_WPI_IOS.app_events_20170816`
WHERE EXISTS(SELECT 1 FROM UNNEST(event_dim) ed WHERE ed.name = 'user_engagement' AND (EXISTS(SELECT 1 FROM UNNEST(ed.params) params WHERE params.key = 'firebase_event_origin' AND value.string_value = 'auto')) AND(EXISTS(SELECT 1 FROM UNNEST(ed.params) params WHERE params.key = 'firebase_screen_class' AND value.string_value = 'TicketViewController')))
您可以使用模拟数据:
WITH data AS(
SELECT ARRAY< STRUCT<name STRING, params ARRAY< STRUCT<key STRING, value STRUCT<string_value STRING> > > > > [STRUCT('user_engagement' AS name, [STRUCT('key' AS key, STRUCT('value' AS string_value) AS value ), STRUCT('firebase_event_origin' AS key, STRUCT('auto' AS string_value) AS value )] AS params)] event_dim UNION ALL
SELECT ARRAY< STRUCT<name STRING, params ARRAY< STRUCT<key STRING, value STRUCT<string_value STRING> > > > > [STRUCT('user_engagement' AS name, [STRUCT('firebase_event_origin' AS key, STRUCT('auto' AS string_value) AS value ), STRUCT('firebase_screen_class' AS key, STRUCT('TicketViewController' AS string_value) AS value )] AS params)] event_dim UNION ALL
SELECT ARRAY< STRUCT<name STRING, params ARRAY< STRUCT<key STRING, value STRUCT<string_value STRING> > > > > [STRUCT('user_engagement' AS name, [STRUCT('firebase_event_origin' AS key, STRUCT('auto' AS string_value) AS value ), STRUCT('firebase_screen_class' AS key, STRUCT('TicketViewController' AS string_value) AS value ), STRUCT('firebase_event_origin' AS key, STRUCT('auto' AS string_value) AS value ), STRUCT('firebase_screen_class' AS key, STRUCT('TicketViewController' AS string_value) AS value )] AS params)] event_dim UNION ALL
SELECT ARRAY< STRUCT<name STRING, params ARRAY< STRUCT<key STRING, value STRUCT<string_value STRING> > > > > [STRUCT('user_not_engagement' AS name, [STRUCT('key' AS key, STRUCT('value' AS string_value) AS value ), STRUCT('firebase_event_origin' AS key, STRUCT('auto' AS string_value) AS value )] AS params)] event_dim
)
SELECT
count(1) screen_views
FROM data
WHERE EXISTS(SELECT 1 FROM UNNEST(event_dim) ed WHERE ed.name = 'user_engagement' AND (EXISTS(SELECT 1 FROM UNNEST(ed.params) params WHERE params.key = 'firebase_event_origin' AND value.string_value = 'auto')) AND(EXISTS(SELECT 1 FROM UNNEST(ed.params) params WHERE params.key = 'firebase_screen_class' AND value.string_value = 'TicketViewController')))
基本上,查询会查找给定事件名称同时触发了指定params
的用户,并计算发生这种情况的所有行。