错误:项目命中未启用BigQuery

时间:2017-05-11 11:37:19

标签: google-bigquery

我尝试使用BigQuery从GA导出数据,但查询失败。

我使用这个功能:

  • FLATTEN

  • TABLE_DATA_RANGE

    因为我需要来自点击的数据。

任何人都可以帮我解决这个错误吗?

错误:

  

项目点击未启用BigQuery

现在,错误是其他错误:找不到字段CampaignGrouping:

SELECT
a.hits.contentGroup.contentGroup2 AS CampaignGrouping,
a.customDimensions.value AS member_PK,
'Web' AS Canal,
'ES' AS country_id,
count(a.hits.contentGroup.contentGroupUniqueViews2) AS VistasUnicas
FROM FLATTEN(FLATTEN(
  (SELECT
  hits.contentGroup.contentGroupUniqueViews2,
  hits.contentGroup.contentGroup2,
  customDimensions.value  
  FROM TABLE_DATE_RANGE([###.ga_sessions_], TIMESTAMP('2017-04-01'), TIMESTAMP('2017-04-30'))), 
  hits.contentGroup.contentGroupUniqueViews2), customDimensions.value
  )a
WHERE hits.contentGroup.contentGroup2<>'(not set)' AND customDimensions.value<>'null' AND hits.contentGroup.contentGroupUniqueViews2 IS NOT NULL
GROUP BY 1,2,3,4
ORDER BY 5 ASC

1 个答案:

答案 0 :(得分:1)

Standard SQL中解决您的问题要比在Legacy中更容易。

此查询可能有助于您计算:

SELECT
  hits.contentgroup.contentgroup2 CampaignGrouping,
  custd.value member_PK,
  'Web' Canal,
  'ES' AS country_id,
  SUM(hits.contentGroup.contentGroupUniqueViews2) VistasUnicas
FROM
  `project_id.dataset_id.ga_sessions_*`,
  UNNEST(customdimensions) custd,
  UNNEST(hits) AS hits
WHERE
  1 = 1
  AND PARSE_TIMESTAMP('%Y%m%d', REGEXP_EXTRACT(_table_suffix, r'.*_(.*)')) BETWEEN TIMESTAMP('2017-05-01') AND TIMESTAMP('2017-05-06')
  and hits.contentGroup.contentGroup2<>'(not set)'
  AND custd.value<>'null'
  AND hits.contentGroup.contentGroupUniqueViews2 IS NOT NULL
GROUP BY
  1, 2
ORDER BY 5 ASC

您只需要enable it,它已经准备好了。

正如您所说,您正在学习SQL,强烈建议您首先学习标准版而不是Legacy版,因为它更稳定,并提供了几种不同的技术来更好地帮助您分析