fyzeri
New Coder
Hi,
I'm trying to make a API call to read data from google storage file and then to write that data to google bigquery. For both currently the region/location is set to EU but somehow I still receive the following API error "google.api_core.exceptions.BadRequest: 400 Cannot read and write in different locations: source: EU, destination: US"
Here is the python file:
from google.cloud import bigquery
client = bigquery.Client()
external_config = bigquery. ExternalConfig("CSV")
external_config.source_uris = [
"gs/😛athwrittenhere"
]
external_config.schema = [
bigquery.SchemaField("name", "STRING"),
bigquery.SchemaField("post_abbr", "STRING"),
]
external_config.csv_options.skip_leading_rows = 1
table_id = "us_states_table"
sql = 'SELECT * FROM `{0}` WHERE name LIKE "W%"'.format(table_id)
job_config = bigquery.QueryJobConfig(table_definitions={table_id: external_config})
query_job = client.query(sql, job_config =job_config)
w_states = list(query_job)
print (w_states)
Is there anyway to fix this or do I have to set up new storage and bigquery projects?
Thank you a lot in advance, Im quite new with these API calls to cloud! All the help is really appreciated.
I'm trying to make a API call to read data from google storage file and then to write that data to google bigquery. For both currently the region/location is set to EU but somehow I still receive the following API error "google.api_core.exceptions.BadRequest: 400 Cannot read and write in different locations: source: EU, destination: US"
Here is the python file:
from google.cloud import bigquery
client = bigquery.Client()
external_config = bigquery. ExternalConfig("CSV")
external_config.source_uris = [
"gs/😛athwrittenhere"
]
external_config.schema = [
bigquery.SchemaField("name", "STRING"),
bigquery.SchemaField("post_abbr", "STRING"),
]
external_config.csv_options.skip_leading_rows = 1
table_id = "us_states_table"
sql = 'SELECT * FROM `{0}` WHERE name LIKE "W%"'.format(table_id)
job_config = bigquery.QueryJobConfig(table_definitions={table_id: external_config})
query_job = client.query(sql, job_config =job_config)
w_states = list(query_job)
print (w_states)
Is there anyway to fix this or do I have to set up new storage and bigquery projects?
Thank you a lot in advance, Im quite new with these API calls to cloud! All the help is really appreciated.