#THIS IS THE CODE I AM RUNNING
# Set the destination table
for i in range(1,13):
table_ref = client.dataset("newdataset").table("chicago_months_increment")
job_config.destination = table_ref
job_config.allow_large_results = True
query_job = client.query('SELECT * FROM `bigquery-public-
data.chicago_taxi_trips.taxi_trips` WHERE (Select EXTRACT(MONTH from
trip_start_timestamp) )=i;',
location='US', # Location must match dataset
job_config=job_config)
rows = list(query_job) # Waits for the query to finish
query_job.result()
# Export table to GCS
destination_uri = "gs://monthly-data/month-"+i+"-*.csv"
dataset_ref = client.dataset("newdataset", project="chicago-project-247714")
table_ref = dataset_ref.table("chicago_months_increment")
extract_job = client.extract_table(
table_ref,
destination_uri,
location='US')
extract_job.result() # Waits for job to complete
client.delete_table(table_ref) #Deletes table in BQ
#ERROR I AM GETTING
---------------------------------------------------------------------------
BadRequest Traceback (most recent call last)
<ipython-input-5-e176648eba58> in <module>()
9 location='US', # Location must match dataset
10 job_config=job_config)
---> 11 rows = list(query_job) # Waits for the query to finish
12
13
/home/amiteshwar/.local/lib/python2.7/site-
packages / google / cloud / bigquery / job.pyc в iter (self) 2988 2989 def iter (self): -> 2990 return iter (self.result ()) 2991 2992
/home/amiteshwar/.local/lib/python2.7/site-
packages / google / cloud / bigquery / job.pyc в result (self, timeout, page_size, retry) 2875 Если задание не было выполнено в течение заданного времени ожидания.2876 "" "-> 2877 super (QueryJob, self) .result (timeout = timeout) 2878 # Возвращать итератор вместо возврата задания. 2879, если не self._query_results:
/home/amiteshwar/.local/lib/python2.7/site-
packages / google/cloud/bigquery/job.pyc в результате (self, timeout, retry) 731 self._begin (retry = retry) 732 # TODO: изменить PollingFuture, чтобы он мог передать аргумент повторения в done (). -> 733 return super(_AsyncJob, self) .result (timeout = timeout) 734 735 def отменено (self):
/home/amiteshwar/.local/lib/python2.7/site-
packages/google/api_core/future/polling.pyc in result(self, timeout)
125 # pylint: disable=raising-bad-type
126 # Pylint doesn't recognize that this is valid in this case.
--> 127 raise self._exception
128
129 return self._result
BadRequest: 400 Unrecognized name: i at [1:125]