BigQuery中Android上每日活跃用户数不正确

时间:2017-07-18 11:22:22

标签: android sql firebase google-bigquery firebase-analytics

在BigQuery中,我使用以下查询来获取每日活跃用户的数量:

`

#legacySQL
SELECT
  user_dim.app_info.app_platform as appPlatform,
  event_dim.date as eventDate,
  COUNT(DISTINCT user_dim.app_info.app_instance_id) as daily_active_users
FROM
  TABLE_QUERY([table_name], 'table_id CONTAINS "app_events_"'),
  TABLE_QUERY([table_name], 'table_id CONTAINS "app_events_"')
GROUP BY
  appPlatform, eventDate
ORDER BY
  appPlatform, eventDate

`

此具体日期查询的结果为534 users for Android and 142 users for IOS

但Firebase显示,今天只有209位活跃的Android用户。 这个数字是正确的,因为我可以将它与Appsee的数据进行比较。 至于IOS,Firebase返回的数字与我在BigQuery中的查询完全相同。

我的查询有什么问题,我该如何解决这个问题?

我也尝试在标准SQL中编写查询: `

#standardSQL
SELECT
  event.date as date,
  COUNT(DISTINCT user_dim.app_info.app_instance_id) AS daily_visitors
FROM `table.table.app_events_*`
CROSS JOIN UNNEST(event_dim) AS event
GROUP BY date
ORDER BY date DESC

` 但是这个查询的结果与前面提到的结果完全相同:每日用户534个而不是Android的209个,这是IOS的正确数字。

所以,我认为问题在于我对内部FB / BQ机制的误解。

请帮我弄清楚问题的根源。

1 个答案:

答案 0 :(得分:0)

进一步查询会返回两个平台的正确每日活跃用户数:

#legacySQL
SELECT
  event_dim.date as eventDate,
  CASE WHEN user_dim.app_info.app_platform = 'IOS' AND EXACT_COUNT_DISTINCT(user_dim.app_info.app_instance_id) !=0 THEN INTEGER(EXACT_COUNT_DISTINCT(user_dim.app_info.app_instance_id))
  ELSE 0
  END as IOS_dau,

  CASE WHEN user_dim.app_info.app_platform = 'ANDROID' AND EXACT_COUNT_DISTINCT(user_dim.app_info.app_instance_id) !=0 THEN INTEGER(EXACT_COUNT_DISTINCT(user_dim.app_info.app_instance_id))
  ELSE 0
  END as ANDROID_dau,  

FROM
  TABLE_QUERY([table:table_IOS], 'table_id CONTAINS "app_events_"'),
  TABLE_QUERY([table:table_ANDROID], 'table_id CONTAINS "app_events_"')
WHERE event_dim.name = 'user_engagement'
GROUP BY 1, user_dim.app_info.app_platform
ORDER BY 1 DESC