【问题标题】:Google Cloud SDK update cause error for bqGoogle Cloud SDK 更新导致 bq 错误
【发布时间】:2018-07-28 16:03:54
【问题描述】:

更新谷歌云 SDK 189.0.0 后,之前正常的命令bq query --nouse_legacy_sql " ... " 现在报错如下:

$ 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. $

恢复以前的版本再次工作。

$ 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

【问题讨论】:

  • 我无法重现这个。升级到 189.0.0,它工作正常。使用的是什么 Python 版本?
  • 我有完全相同的错误。发生这种情况的地方是我很久以前设置的一个在 Compute Engine 上运行的 VM。我正在调用的 bq 程序来自 /usr/local/bin/bq,它是 /usr/local/share/google/google-cloud-sdk/bin/bq 的符号链接 - 不确定这是否相关。
  • 要添加更多关于我之前的评论,这里是一个版本列表:gist.github.com/ronoaldo/14dbb69184594fc0e59771f698b95a76
  • 如果您删除 ~/.bigqueryrc 和相关的旧版 bigquery 凭据,它也会失败。
  • 升级后我遇到了同样的错误...运行“恢复”解决了这个问题。我还注意到 bin/ 中的“bq”自 9 月以来没有改变。

标签: google-bigquery gcloud


【解决方案1】:

如果您之前的状态良好,您可以通过执行以下命令将升级恢复到 189.0.0:

gcloud components restore

这样做会将我的 SDK 恢复为 172.0.1,将 bq 恢复为 2.0.26,我可以再次从 VM 执行这两个版本。

$ 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 |
+--------+

【讨论】:

    【解决方案2】:

    尝试撤销并初始化您的 gcloud 凭据:

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

    或者用你用来验证的命令替换'login',如果它不同的话。

    【讨论】:

    • gcloud auth init 似乎不是一个有效的命令。你的意思是gcloud auth login 还是gcloud auth application-default login?我试过这个,它清除了 OP 问题,但导致“无法访问 ~/.config/gcloud/legacy_credentials/XXXXX/singlestore_bq.json:没有这样的文件或目录”。无论如何,这些似乎是解决这个问题的一个相当大的变化。
    • 那个“singlestore_bq.json”错误信息似乎在第一次运行后就消失了,所以我认为它会自行清理。
    • 谢谢,我更新了答案。是的,我的意思是“登录”。很高兴它成功了。
    • 我不确定要撤销哪个“凭据”,所以我只是将 ~/.config/gcloud 移动到新位置(作为备份),然后运行 ​​gcloud auth login,然后运行 ​​gcloud config set项目,这似乎把事情弄清楚了。
    猜你喜欢
    • 2023-04-07
    • 2014-02-05
    • 1970-01-01
    • 2013-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-09
    • 2021-11-04
    相关资源
    最近更新 更多