在BigQuery中以标准SQL格式编写遗留视图 [英] writing legacy views in Standard SQL format in Bigquery

查看:278
本文介绍了在BigQuery中以标准SQL格式编写遗留视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我问了这个问题,我正在努力在标准SQL中编写我的遗留视图。



我的表格是

  FROM [myProject.Mydataset.ga_sessions_20171129] 

ga_sessions_20171129是我的表格ID,其名称的最后部分显示了表格更新的最后日期,因此第二天的下一个表格将是20171130



我们使用此代码每天更新表格

  FROM`project.dataset.ga_sessions_ *`
WHERE _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d',CURRENT_DATE())

但它不起作用,并给我这个错误:


保存视图失败。视图不能通过前缀查询。部分
的匹配视图列表是:...

后来,我们认为因为我们有一些类似的表ga_sessions_S_20171129,它引起了一些混淆,然后我们尝试了这种方式。

  FROM`project.dataset.ga_sessions_20 *`where _TABLE_SUFFIX = FORMAT_DATE(' %y%m%d',CURRENT_DATE())

它仍然不起作用。有没有人有这方面的线索?

解决方案

我看到的唯一解释是,在同一数据集中,您有与其他表具有相同前缀的视图 - 这是 project.dataset.ga_sessions _ * 但通配符表不支持视图。如果通配符表与数据集中的任何视图匹配,则查询将返回错误。

还有一些通配符表的限制


I asked this question yesterday, I'm trying to write my legacy view in standard SQL.

My table is

FROM [myProject.Mydataset.ga_sessions_20171129]

ga_sessions_20171129 is my table id and the last part of its name shows the last date that the table is updated, so the next table for the next day will be 20171130

We used this code to update the table every day

FROM `project.dataset.ga_sessions_*` 
WHERE _TABLE_SUFFIX = FORMAT_DATE('%Y%m%d', CURRENT_DATE())

But it didn't work and gave me this error:

Failed to save view. Views cannot be queried through prefix. Partial list of the matched views are:...

Later, we thought that because we have some tables like that ga_sessions_S_20171129, it caused some confusion, then we tried this

FROM `project.dataset.ga_sessions_20*` where _TABLE_SUFFIX = FORMAT_DATE('%y%m%d', CURRENT_DATE())

It still doesn't work. Does anyone have a clue about this?

解决方案

The ONLY explanation I see is that in same dataset you have view that has same prefix as other tables - which is project.dataset.ga_sessions_* but wildcard table does not support views. The query returns an error if the wildcard table matches any views in the dataset

There are few more limitations for wildcard tables

这篇关于在BigQuery中以标准SQL格式编写遗留视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆