Reputation: 345
I've changed some configurations on BigQuery and actually I can't fetch data anymore.
This is the flow:
$query = "select what i need to select";
$client = new Google_Client();
$client->setApplicationName('Google-BigQuery');
$client->useApplicationDefaultCredentials(); // running in app engine env
$client->addScope('https://www.googleapis.com/auth/bigquery');
$client->addScope('https://www.googleapis.com/auth/devstorage.read_write');
$bq = new Google_Service_Bigquery($client);
$job = new Google_Service_Bigquery_Job();
$config = new Google_Service_Bigquery_JobConfiguration();
$queryConfig = new Google_Service_Bigquery_JobConfigurationQuery();
$config->setQuery($queryConfig);
$job->setConfiguration($config);
$queryConfig->setQuery($query);
Then:
$job = $bq->jobs->insert($project, $job); // OK
$jr = $job->getJobReference(); // OK -> here i got jobid as $jr['jobId']
$queryResults = $bq->jobs->getQueryResults('my-project', 'job-id-from-jr'); // ERROR
If I run the query from BigQuery dashboard, it's work and I can get results. Here I got a 404 error, "notfound", I've checked if the job id match with that on the dashboard, and it match. { "error": { "code": 404, "message": "Not found: Job my-project:job-id",
The only one difference is that on the job inside the dashboard is specified the location as
my-name:europe-west1.job-id
Can't find a way to specify directly the zone of execution, I've tried to add europe-west1 as a string before job-id, but got error about that (it can't be done).
There is a way to fix this? It's possible to specify the zone?
Thanks!
Upvotes: 0
Views: 520
Reputation: 345
Ok, solved by passing an array as 3rd parameter
$arrLocation = array("location" => "europe-west1");
$queryResults = $bq->jobs->getQueryResults('my-project', 'job-id-from-jr', $arrLocation);
Upvotes: 1