We've recently implemented Firebase in one of our games and have configured multiple custom events & parameters per event in the same. The structure of the events is the same as what has been defined/shared in Firebase BigQuery DB (Link)
Currently, I am using the below query to take out the data:
SELECT
user_dim.app_info.app_instance_id AS id,
(
SELECT
param.value.int_value
FROM
UNNEST(event_dim.params) AS param
WHERE
param.key = 'x') AS x,
(
SELECT
param.value.int_value
FROM
UNNEST(event_dim.params) AS param
WHERE
param.key = 'y') AS y,
(
SELECT
param.value.string_value
FROM
UNNEST(event_dim.params) AS param
WHERE
param.key = 'z') AS z
FROM
`firebase_dataset`
CROSS JOIN
UNNEST(event_dim) AS event_dim
WHERE
event_dim.name = 'event_name';
This gives a list of all the data for the parameters in the said event. For example,
id x y z
1 100 1000 abc
1 200 1500 def
1 300 2000 ghi
1 400 2500 klm
2 100 1000 abc
2 200 1500 def
3 100 1000 abc
4 100 1000 abc
4 200 1500 def
4 300 2000 ghi
We then take the CSV and then take out the counts for x, y and z separately or unique counts of "id" where x, y or z occurred.
For example,
X Count of id
100 4
200 3
300 2
400 1
I know that it's possible to get the unique count / over count values directly through queries but I haven't been able to figure out how for multiple parameters in bigquery.
I am assuming a better query would help decrease the time taken to run but won't change the data being queried as much as the dataset to get the end result won't change much.
Any help on how to make the result come through directly on BigQuery would be highly appreciated.
Thanks!
Regards, Tejas