简体   繁体   English

无法从DataLab查询表

[英]Cannot query table from datalab

I have a dataset with tables set up within Big Query which I can query just fine using the BQ UI, however I am getting an error when attempting to run a standard query from datalab. 我有一个包含在Big Query中设置的表的数据集,可以使用BQ UI进行查询,但是尝试从datalab运行标准查询时出现错误。

I can get the table schema returned when I run 我可以在运行时获取返回的表架构

%%bq tables describe --name "my-project.my_dataset.my_table"

and also I can get access to the meta data 而且我也可以访问元数据

table1=bq.Table("my-project.my_dataset.my_table")
table1.metadata.rows

Result: 637043

However when I run 但是当我跑步时

%%bq query --name testQuery 
SELECT * FROM `my-project.my_dataset.my_table`

I receive the error 我收到错误

RequestException: HTTP request failed: Not found: Job my-project:job__SSPF9nCudKqIFZT8N4yvp_SUDb5

I have tried using the various different ways of sending the same query as well as sampling but no joy. 我尝试使用各种不同的方式来发送相同的查询以及进行采样,但没有乐趣。

Has anyone experienced a similar issue? 有没有人遇到过类似的问题?

Had the same problem and found the solution here: 遇到相同的问题,并在此处找到解决方案:

https://cloud.google.com/bigquery/docs/visualize-jupyter https://cloud.google.com/bigquery/docs/visualize-jupyter

Try to install this library: 尝试安装此库:

pip install google-cloud-bigquery[pandas]

Call the magic notebook command: 调用魔术笔记本命令:

%load_ext google.cloud.bigquery

And then run the query this way: 然后以这种方式运行查询:

%%bigquery
SELECT
    source_year AS year,
    COUNT(is_male) AS birth_count
FROM `bigquery-public-data.samples.natality`
GROUP BY year
ORDER BY year DESC
LIMIT 15

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM