Reputation: 35
Could somebody explain me why I am getting an syntax error in the following code:
$ bq query --allow_large_results --destination_table=clients.tab_cl1 "SELECT * from adagency-167918:sourcedataset.src_table$20170516 where advertiserid=1 and timestamp="2017-05-16""
and this is the error I am getting:
Error in query string: Error processing job 'adagency-167918:bqjob_r215d56938dbaa2b7_0000015c1a4c2932_1': Encountered " "-" "- "" at line 1, column 31. Was expecting:
Upvotes: 1
Views: 3618
Reputation: 33745
Edit: the problem is unrelated to using bq
, actually, although the $
is problematic. When you are using legacy SQL, you need to use [
and ]
to escape the table name if the project includes a hyphen. For example,
[your-project:dataset.table]
With standard SQL, you use backticks:
`your-project.dataset.table`
So your query should be:
bq query --allow_large_results \
--destination_table=clients.tab_cl1 \
"SELECT * from [adagency-167918:sourcedataset.src_table\$20170516] where advertiserid=1 and timestamp=timestamp('2017-05-16')"
Upvotes: 1