Quentin
Quentin

Reputation: 1037

bigquery dataset name starting with a number and TABLE_DATE_RANGE

I'm using bigquery with a dataset called '87891428' containing daily tables. I try to query a dates range thanks to the function TABLE_DATE_RANGE:

SELECT avg(foo) 
FROM (
      TABLE_DATE_RANGE(87891428.a_abc_, 
                       TIMESTAMP('2014-09-30'),
                       TIMESTAMP('2014-10-19'))
     )

But this leads to a very explicit error message:

Error: Encountered "" at line 3, column 21. Was expecting one of:

I've the feeling that TABLE_DATE_RANGE doesn"t like to have a dataset starting with a number cause when I copy few tables into a new dataset called 'test' the query run properly. Does anyone has already encountered this issue and if so what is the best workaround (as far as I know you can't rename a dataset) ?

Upvotes: 1

Views: 2045

Answers (1)

Jordan Tigani
Jordan Tigani

Reputation: 26637

The fix for this is to use brackets around the dataset name and table prefix:

SELECT avg(foo) 
FROM (
      TABLE_DATE_RANGE([87891428.a_abc_], 
                       TIMESTAMP('2014-09-30'),
                       TIMESTAMP('2014-10-19'))
     )

Upvotes: 2

Related Questions