4

I keep getting an error using the bqcommand line tool. For example, I can easily run this query and it returns the table that I want:

head -n 10 xxxx-bq:name_name.Report2

Note that xxxx-bq is the projectid, and name_name is the dataset id. When I try to run a query against this table, say the follwing:

query "SELECT count(*) FROM xxxx-bq:name_name.Report2

I get an error that says that I cannot start a job without a project id. What am I doing wrong here? How can I specify in the query the project ID? I know people have asked some similar questions. That said, I have been following along and my approach is not working.

2 Answers 2

5

Do you have a project id? If not, this page can help you set one up: https://developers.google.com/bigquery/bq-command-line-tool-quickstart

All BigQuery jobs (which include queries) require a project id, which is the project that gets billed for any damage done by the job. (by damage, I mean work) You should either set your default project id (you can do this by running bq init) or set the project id that you're running the job under via --project_id=

So if you're running bq shell, you would use bq shell --project_id=myprojectid instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Great point. I do have a project id. What I ended up doing was setting the project as my default in the default config file for BQ. Then, I was able to cleanly execute queries. This should work nicely as a start. Thanks Jordan for the help!
0

strange... I just started working with bq & got the same error but it didn't like me passing --project_id=[myprojectid]. Although I was already authed with gcloud auth login, I had to run bq init (and it seemingly didn't do anything) -- after that, my queries worked just fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.