我被困在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表中以不同的方式访问会有什么问题?