3

I'm trying to log events and specify the moment these moments happened.

For example:

Firebase.Analytics.FirebaseAnalytics.LogEvent ("EventGamePlayed", "sent_at", DateTime.Now.ToString ("yyyy-MM-dd hh:mm:ss"));

I would like to know if it's possible that, once it's exported to BigQuery, I could use this parameter as a date / timestamp so I can, for example, get all the X or Y events that happened last month.

Thanks!

1 Answer 1

5

You probably don't need this, actually. Referring to the Firebase schema for BigQuery exports, you can use either date or timestamp_micros within event_dim. For example, to find events on April 1, you could do:

#standardSQL
SELECT event
FROM YourTable
CROSS JOIN UNNEST(event_dim) AS event
WHERE PARSE_DATE('%Y%m%d', event.date) = '2017-04-01';

To find events that occurred between 12pm and 4pm UTC on April 1, you could do:

#standardSQL
SELECT event
FROM YourTable
CROSS JOIN UNNEST(event_dim) AS event
WHERE TIMESTAMP_MICROS(event.timestamp_micros) BETWEEN
  '2017-04-01 12:00:00' AND '2017-04-01 16:00:00';
3
  • This will work, but the benefit of converting data to actual DATE or TIMESTAMP types - is that these queries will work much faster - filter on plain comparison of dates/timestamp can be pushed deeper Commented Apr 26, 2017 at 14:17
  • Firebase does not support DATE or TIMESTAMP types in events; they can only be of types STRING, INT64, or FLOAT64, so that isn't an option. Commented Apr 26, 2017 at 14:20
  • But when data is loaded into BQ - it can be transformed using PARSE_DATE/TIMESTAMP_MICROS functions to become of right type. Commented Apr 26, 2017 at 14:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.