我使用相同的逻辑来取消hit.eCommerceAction,但它不像其他字段那样工作.有关这个问题的任何帮助?另外,max(if())函数是否是用于获取两个hits.customeDimenison.value的正确函数?
SELECT Date ,COUNT(DISTINCT FULLVISITORID) , product.v2ProductCategory ,max(if(customDimensions.index=2, customDimensions.value,null)) as dest ,max(if(customDimensions.index=21, customDimensions.value,null)) as pax ,eCommerceAction.action_type ,product.v2ProductName FROM `table` as t CROSS JOIN UNNEST(hits) AS hit CROSS JOIN UNNEST(hit.customDimensions) AS customDimensions CROSS JOIN UNNEST(hit.eCommerceAction) as eCommerceAction CROSS JOIN UNNEST(hit.product) AS product GROUP BY Date ,product.v2ProductCategory ,eCommerceAction.action_type ,product.v2ProductName
我得到的错误代码是错误:UNNEST中引用的值必须是数组.UNNEST包含STRUCT类型的表达式
我可以使用更简单的查询重现错误:
#standardSQL SELECT DISTINCT hit.eCommerceAction.action_type FROM `73156703.ga_sessions_20170109` t , UNNEST(hits) hit , UNNEST(hit.customDimensions) customDimensions , UNNEST(hit.eCommerceAction) as eCommerceAction
这里的问题是它eCommerceAction
不是REPEATED
记录,因此没有数组UNNEST
.
固定查询:
#standardSQL SELECT DISTINCT hit.eCommerceAction.action_type FROM `ga_sessions_20170109` t , UNNEST(hits) hit , UNNEST(hit.customDimensions) customDimensions