How to run a run a BigQuery job programmatically

0 votes
I have a big query job that I need to run programmatically. How do I do it?
Nov 15, 2019 in GCP by anonymous
• 6,260 points
1,529 views

1 answer to this question.

0 votes

To run a job programmatically:

  1. Start the job by calling the jobs.insert method. When you call the jobs.insert method, include a job resource representation that contains:

    • Your location in the location property in the jobReference section.

    • The job ID generated by your client code. The server generates a job ID for you if you omit it, but it is a best practice to generate the job ID on the client side to allow reliable retry of the jobs.insert call.

      For example:

      {
        "jobReference": {
          "projectId": "my_project",
          "jobId": "job_123",
          “location”: “asia-northeast1”
        },
        "configuration":
        {
          // ..
        },
      }
      
      
  2. In the configuration section of the job resource, include a child property that specifies the job type — load, query, extract, or copy.

  3. After calling the jobs.insert method, check the job status by calling jobs.get with the job ID and location, and check the status.state value to learn the job status. When status.state is DONE, the job has stopped running; however, a DONE status does not mean that the job completed successfully, only that it is no longer running.

  4. Check for job success. If the job has an errorResult property, the job has failed. The status.errorResult property holds information describing what went wrong in a failed job. If status.errorResult is absent, the job finished successfully, although there might have been some non-fatal errors, such as problems importing a few rows in a load job. Non-fatal errors are returned in the job's status.errors list.

answered Nov 15, 2019 by Sirajul
• 59,230 points

Related Questions In GCP

0 votes
1 answer

Schedule a query to run every 3 hours in my BigQuery project.

 Use the bq query command. With this method, you will ...READ MORE

answered Nov 21, 2019 in GCP by anonymous
• 59,230 points
2,817 views
0 votes
1 answer

How can I tell how much it costs to run a low traffic WordPress site on GCP?

Running a 2x g1-small (1 vCPU, 1.7 ...READ MORE

answered Apr 6, 2022 in GCP by Korak
• 5,820 points
551 views
0 votes
1 answer

How to delete a project from Google Cloud Console

First of all, select the project you ...READ MORE

answered Apr 18, 2018 in GCP by kurt_cobain
• 9,350 points
2,884 views
0 votes
1 answer
0 votes
1 answer

Does Google cloud platform (GCP) offer IaaS ? Or just PaaS?

GCP provides IaaS as well, although it ...READ MORE

answered Sep 20, 2019 in GCP by Sirajul
• 59,230 points
7,009 views
0 votes
1 answer

How do I create a VPCN (Virtual private cloud network) on Google Cloud?

You can connect various GCP resources to each ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 59,230 points
1,815 views
0 votes
1 answer

Cloud SQL of google cloud is IaaS or PaaS?

Cloud SQL is PAAS (Plaform As A ...READ MORE

answered Sep 23, 2019 in GCP by Sirajul
• 59,230 points
3,978 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP