Google BigQuery尝试运行TABLE_RANGE_DATE

时间:2022-06-01 21:37:03

i am building a partition based table in a dataset and i am trying to query those partitions using a date range.

我正在数据集中构建一个基于分区的表,我试图使用日期范围查询这些分区。

Here is an example of the data:

以下是数据示例:

Dataset: logs Tables: logs_20170501 logs_20170502 logs_20170503

数据集:日志表:logs_20170501 logs_20170502 logs_20170503

i am trying first the TABLE_RANGE_DATE

我首先尝试TABLE_RANGE_DATE

SELECT count(*) FROM TABLE_DATE_RANGE([logs.logs_], TIMESTAMP("2017-05-01"), TIMESTAMP("2017-05-03")) as logs_count

SELECT count(*)FROM TABLE_DATE_RANGE([logs.logs_],TIMESTAMP(“2017-05-01”),TIMESTAMP(“2017-05-03”))as logs_count

i am keep getting : "ERROR:Error evaluating subsidiary query"

我一直得到:“错误:评估辅助查询时出错”

i tried those options as well: single comma: SELECT count(*) FROM TABLE_DATE_RANGE([logs.logs_], TIMESTAMP('2017-05-01'), TIMESTAMP('2017-05-03')) as logs_count Add Project ID: SELECT count(*) FROM TABLE_DATE_RANGE([main_sys_logs:logs.logs_], TIMESTAMP('2017-05-01'), TIMESTAMP('2017-05-03')) as logs_count

我也尝试了这些选项:单个逗号:SELECT count(*)FROM TABLE_DATE_RANGE([logs.logs_],TIMESTAMP('2017-05-01'),TIMESTAMP('2017-05-03'))as logs_count Add Project ID:SELECT count(*)FROM TABLE_DATE_RANGE([main_sys_logs:logs.logs_],TIMESTAMP('2017-05-01'),TIMESTAMP('2017-05-03'))as logs_count

And it didn't worked.

它没有奏效。

So i tried to use TABLE_SUFFIX

所以我试着使用TABLE_SUFFIX

SELECT count(*) FROM [main_sys_logs:logs.logs_*] WHERE _TABLE_SUFFIX BETWEEN '20170501' AND '20170503'

SELECT count(*)FROM [main_sys_logs:logs.logs_ *] WHERE _TABLE_SUFFIX BETWEEN'20170501'EN'20170503'

And i got this error : Invalid table name:'main_sys_logs:logs.logs_*

我收到此错误:表名无效:'main_sys_logs:logs.logs_ *

i have been switching SQL Dialect between legacy SQL ON/Off and i just got different errors on the table name part.

我一直在旧版SQL ON / Off之间切换SQL Dialect,我只是在表名部分有不同的错误。

Is there any tips or help for this matter ? maybe my table name is build wrong with the "_" at the end and this is causing the problem ? thanks for any help.

这件事有什么提示或帮助吗?也许我的表名在最后用“_”构建错误,这导致了问题?谢谢你的帮助。

1 个解决方案

#1


0  

So i tried this Query and it worked :

所以我尝试了这个查询并且它有效:

SELECT count(*) FROM TABLE_DATE_RANGE(logs.logs_, TIMESTAMP("2017-05-01"), TIMESTAMP("2017-05-03")) as logs_count

SELECT count(*)FROM TABLE_DATE_RANGE(logs.logs_,TIMESTAMP(“2017-05-01”),TIMESTAMP(“2017-05-03”))as logs_count

it started to work after i run this query , i don't know if this is the reason .. but i just query the TABLES data for the dataset

它运行此查询后开始工作,我不知道这是否是原因..但我只是查询数据集的TABLES数据

SELECT * FROM logs__TABLES__

SELECT * FROM logs__TABLES__

#1


0  

So i tried this Query and it worked :

所以我尝试了这个查询并且它有效:

SELECT count(*) FROM TABLE_DATE_RANGE(logs.logs_, TIMESTAMP("2017-05-01"), TIMESTAMP("2017-05-03")) as logs_count

SELECT count(*)FROM TABLE_DATE_RANGE(logs.logs_,TIMESTAMP(“2017-05-01”),TIMESTAMP(“2017-05-03”))as logs_count

it started to work after i run this query , i don't know if this is the reason .. but i just query the TABLES data for the dataset

它运行此查询后开始工作,我不知道这是否是原因..但我只是查询数据集的TABLES数据

SELECT * FROM logs__TABLES__

SELECT * FROM logs__TABLES__