Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud SDK update cause error for bq

After updating Google Cloud SDK 189.0.0, previously fine command bq query --nouse_legacy_sql " ... " now error as follow:

$ python --version Python 2.7.13 :: Anaconda, Inc. $ bq version This is BigQuery CLI 2.0.29 $ bq query --nouse_legacy_sql "SELECT country, model, iid, version, count(*) as n, max(t) AS t FROM an6.sm GROUP BY country, model, iid, version ORDER BY t DESC LIMIT 10 " bq.py should not be invoked. Use bq command instead. $

Restoring previous version work again.

$ gcloud components restore
Your Cloud SDK installation will be restored to its previous state.

Do you want to continue (Y/n)?  Y

Restoring backup...

Performing post processing steps...done.
Restoration done!

$ bq query --nouse_legacy_sql "SELECT country, model, iid, version, count(*) as n, max(t) AS t FROM an6.sm GROUP BY country, model, iid, version ORDER BY t DESC LIMIT 10 "
Waiting on bqjob_r13976b38780fa35_00000161ab5076fe_1 ... (1s) Current 
status: DONE
like image 413
Kyaw Tun Avatar asked Feb 18 '18 05:02

Kyaw Tun


People also ask

How do you handle errors in BigQuery?

BigQuery treats ERROR in the same way as any expression that may result in an error: there is no special guarantee of evaluation order. BigQuery infers the return type in context. In the following example, the query returns an error message if the value of the row does not match one of two defined values.

How do I know if GCP SDK is installed?

The first thing to do after successful installation is open your command line and type “gcloud” to check whether Cloud SDK has installed perfectly. Run “gcloud init”, it opens up a new browser window and asks to login into your google cloud account.

Where is Google Cloud SDK stored?

The google-cloud-sdk directory is in your HOME because that's where you extracted it :) From the quickstart instructions: Extract the archive to any location on your file system; preferably, your home directory. So your home directory is the recommended location, but you can put it wherever you'd like.


2 Answers

Try revoking and initializing your gcloud credentials:

gcloud auth revoke <credentials you're using>
gcloud auth login

or replace 'login' with the command you used to authenticate, if it was different.

like image 89
Daria Avatar answered Oct 23 '22 03:10

Daria


If your previous state was a good one, you can revert the upgrade to 189.0.0 by executing:

gcloud components restore

Doing this reverted my SDK back to 172.0.1 and bq to 2.0.26 both which I could execute from the VM again.

$ bq query "SELECT COUNT(word) FROM [bigquery-public-data:samples.shakespeare] LIMIT 1000" 
Waiting on bqjob_r1ac52f8ef09f41c2_00000161a981cfac_1 ... (0s) Current status: DONE   
+--------+
|  f0_   |
+--------+
| 164656 |
+--------+
like image 1
Ronoaldo Pereira Avatar answered Oct 23 '22 03:10

Ronoaldo Pereira