Database Reference
In-Depth Information
There is no need to set sourceUris in the load configuration because
BigQuery is going to use the uploaded data as the source. Using the client
libraries hides the details of how the data is transferred, but it is useful to
understand what is happening under the covers.
Like every REST (as covered in Chapter 4, “Understanding the BigQuery
Object Model,” and Chapter 5) creation operation, the initial insert request
is an HTTP POST request specifying the full configuration of the job in the
body of the request with one crucial difference. Instead of posting to:
https://www.googleapis.com/\
bigquery/v2/projects/${PROJECT_ID}/jobs
the following variant is used:
https://www.googleapis.com/upload/bigquery/
v2\ /projects/${PROJECT_ID}/jobs?uploadType=resumable
When this alternative URL is used, the request is handled a little differently.
Initial error checking is performed, but instead of fully processing the
request (strictly it cannot complete processing because the bytes have not
yet been supplied), a location to upload the data is returned as an HTTP
header in the response. Here is an example initial request:
$ BASE_URL=https://www.googleapis.com/upload/bigquery/
v2
$ PROJECT_ID=317752944021
$ PROJECT_URL=${BASE_URL}/projects/${PROJECT_ID}
$ curl -D - -H "$(python auth.py)" \
-H 'Content-Type: application/json' \
-H 'X-Upload-Content-Type: application/
octet-stream' \
-H 'X-Upload-Content-Length: 2000000' \
--data-binary '{}' \
${PROJECT_URL}/jobs?uploadType=resumable
HTTP/1.1 200 OK
Location: https://www.googleapis.com/upload/bigquery/
v2/projects\…
Cache-Control: no-cache, no-store, max-age=0,
must-revalidate
Pragma: no-cache
Search WWH ::




Custom Search