Google BigQuery:我看到缺少“ clientId”列,但实际上存在于表的架构中

时间:2019-06-11 09:50:10

标签: google-analytics google-bigquery

Google BigQuery:与UNION一起使用时,我的所有查询均引发错误:
“ UNION ALL中的查询具有不匹配的列数;查询1具有17列,查询2具有18列”

当我单独运行查询时,我看到缺少“ clientId”列,但实际上存在于表中。请在下面找到查询。

在分析模式下,该列怎么可能出现在一个dataset.table中,而不出现在另一个dataset.table中?

如何解决此问题?

FROM
    (
    SELECT 
        'web' AS platform
        ,a.*
        ,a._TABLE_SUFFIX AS TABLE_SUFFIX
        from `[project].[dataset for Web].ga_sessions_*` a        
     where 
      _table_suffix BETWEEN  '20190401' AND '20190401'
    ) web
UNION ALL
SELECT android.*
FROM
    (
    SELECT 
        'android' AS platform
        ,a.*
        ,a._TABLE_SUFFIX AS TABLE_SUFFIX
        from `[project].[dataset for Android].ga_sessions_*` a   
     where 
       _table_suffix BETWEEN  '20190401' AND '20190401'
    ) android```

1 个答案:

答案 0 :(得分:0)

以您的查询为基础,我运行了以下查询,该查询已正确执行:

SELECT *
FROM
(
  SELECT
    'web' AS platform,
    a.*,
    a._TABLE_SUFFIX AS TABLE_SUFFIX
  FROM
    `bigquery-public-data.google_analytics_sample.ga_sessions_*` a
  WHERE
    _table_suffix BETWEEN '20170801' AND '20170801'
  LIMIT 5) web
UNION ALL
SELECT
  android.*
FROM (
  SELECT
    'android' AS platform,
    a.*,
    a._TABLE_SUFFIX AS TABLE_SUFFIX
  FROM
    `bigquery-public-data.google_analytics_sample.ga_sessions_*` a
  WHERE
    _table_suffix BETWEEN '20170801' AND '20170801'
  LIMIT 5) android

考虑到您获得的错误消息,注释中的documentation和数据集迁移,看来migrated dataset是不完整的。

考虑到目标表上的BigQuery export schema,也许尝试进行新的数据集迁移可能有助于减轻不完整的信息。

由于我的信誉不高,这就是发布此答案的原因。