Google BigQuery getQueryResults returning 404 Error for valid Job Id

google-bigquery

Solution

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.

Problem

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(); ```

Original source

Related problems