无法查询重复字段event_params.key和user_properties.key与每日事件表的叉积

时间:2018-09-01 17:14:43

标签: google-bigquery

如果我不介意,问题是我需要平整两个字段才能使查询正常工作...下面要讨论的字段是event_params.value.string_value和user_properties.value.string_value

我可以用一个表正确地做到这一点,但是我需要跨越日期的日期范围,并且语法不正确。有帮助吗?

SELECT
  event_params.value.string_value,
  event_timestamp,
  event_name,
  user_properties.value.string_value
FROM
  (TABLE_DATE_RANGE([[kiehls-kinetic:analytics_180943775.events_],
    DATE_ADD(CURRENT_TIMESTAMP(), -365, 'DAY'),
    CURRENT_TIMESTAMP())),
WHERE
  (event_params.key = 'session')
  AND (user_properties.key = 'associate_name')

ORDER BY
  event_params.value.string_value ASC,
 event_timestamp ASC

1 个答案:

答案 0 :(得分:0)

您想要使用标准SQL这样的内容:

SELECT
  (SELECT value.string_value
   FROM UNNEST(event_params)
   WHERE key = 'session') AS event_value,
  event_timestamp,
  event_name,
  (SELECT value.string_value
   FROM UNNEST(user_properties)
   WHERE key = 'associate_name') AS user_value
FROM
  `kiehls-kinetic.analytics_180943775.events_*`
WHERE _TABLE_SUFFIX BETWEEN
  FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 365 DAY)) AND
  FORMAT_DATE('%Y%m%d', CURRENT_DATE())
ORDER BY
  event_value ASC,
  event_timestamp ASC