我一直在对我的 gcp 的 jupyter 笔记本使用查询。当我在那里运行时,查询在 Bigquery 中运行良好(见下图)
当我使用此代码在笔记本中运行它时。
query = """SELECT *, FROM [kaggle-competition-datasets:geotab_intersection_congestion.train] LIMIT 4"""
import google.datalab.bigquery as bq
train = bq.Query(query).execute().result().to_dataframe()
我得到这个错误。
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/google/datalab/bigquery/_query.py in execute_async(self, output_options, sampling, context, query_params)
278 try:
--> 279 destination = query_result['configuration']['query']['destinationTable']
280 table_name = (destination['projectId'], destination['datasetId'], destination['tableId'])
KeyError: 'destinationTable'
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
<ipython-input-1-85e1ffdadde6> in <module>
1 query = """SELECT *, FROM [kaggle-competition-datasets:geotab_intersection_congestion.train] LIMIT 4"""
2 import google.datalab.bigquery as bq
----> 3 train = bq.Query(query).execute().result().to_dataframe()
/usr/local/lib/python3.5/dist-packages/google/datalab/bigquery/_query.py in execute(self, output_options, sampling, context, query_params)
337 """
338 return self.execute_async(output_options, sampling=sampling, context=context,
--> 339 query_params=query_params).wait()
340
341 @staticmethod
/usr/local/lib/python3.5/dist-packages/google/datalab/bigquery/_query.py in execute_async(self, output_options, sampling, context, query_params)
281 except KeyError:
282 # The query was in error
--> 283 raise Exception(_utils.format_query_errors(query_result['status']['errors']))
284
285 execute_job = _query_job.QueryJob(job_id, table_name, sql, context=context)
Exception: invalidQuery: Syntax error: Unexpected "[" at [1:16]. If this is a table identifier, escape the name with `, e.g. `table.name` rather than [table.name].
当然,我按照回溯的建议修改了查询,但没有任何效果。gcp 中的笔记本在 bigquery 表中以不同方式访问有什么问题?