3
votes

I have created Google query job with my own job id successfully. And able to use the job id again and got successful results yesterday. But the same Job id not working fine. I have tried the job id with project Id in the google bigquery UI got the same error as '404' below

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found: Table<projectId:some random generated String.some random generated String>"
   }
  ],
  "code": 404,
  "message": "Not Found: Table <projectId:some random generated String.some random generated String>
 }
}

Please help me, is there any life time for Job? Or any specific Configuration required while creating Job Id to work permanently?

I am using Java API of Google Bigquery to do the above implementation. Find the logic used below: Query Job Creation logic:

String query = "SELECT count(*) AS TOTAL_RECORDS FROM :dataset.:tablename;"

    String expectedJobId = "someuniqueString";
    JobConfigurationQuery queryConfig = new JobConfigurationQuery()
                        .setQuery(query);
                queryConfig.setUseQueryCache(true);

                JobConfiguration config = new JobConfiguration()
                        .setQuery(queryConfig);

                JobReference jobReference = new JobReference();
                jobReference.setJobId(expectedJobId);
                jobReference.setProjectId(PROJECT_ID);

                Job job = new Job().setId(expectedJobId).setConfiguration(
                        config);
                job.setJobReference(jobReference);
                            job = bigqueryService.jobs()
                                    .insert(PROJECT_ID, job).execute();

Results Retrieved using above JobId :

GetQueryResults queryRequest = bigqueryService.jobs()
                    .getQueryResults(PROJECT_ID, expectedJobId);
            GetQueryResultsResponse queryResponse = queryRequest.execute();
2
What does your request look like? Can you show the request and response from the request to create the Job? - Jason Hall
Jason, I have added more details about request creation logic. any other details you want? - Ganesh
I don't think you get to specify the job ID. Any value you provide will be ignored. Instead of using expectedJobId you should use job.getId() -- see if that helps - Jason Hall
Jason, the expected job id is properly set as job Id in big query and works fine for more than a day. But after that it is not working. And job.getId() provides same value. - Ganesh

2 Answers

2
votes

The error you're seeing is not a problem looking up the job but looking up the result table. As you noticed, getQueryResults() for a particular job will only work for up to 24 hours; after that the table that is created to store the results will expire and get cleaned up.

If you find that this happens within the 24 hour window, you might want to check to make sure the job actually completed successfully. You can use bigqueryService.jobs.get() to look up the job status.

If that doesn't help, if you send the job id we (the BigQuery team) can look up in the server logs what is going on with that job.

0
votes

Sometimes the problem is incorrect dataset location. In my code I have a config based on which I set the dataset location while executing a query. I messed up the location and started getting this error. After 2 hours of debugging finally found the issue.

Corrected the dataset location and it worked fine.