runt18 / google-bigquery

Automatically exported from code.google.com/p/google-bigquery
0 stars 0 forks source link

Extract job in GBQ API Explorer destinationUri deprecated, but required in PHP request #465

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When submitting an extract job in GBQ API explorer, the interface says that 
configuration->extract->destinationUri is deprecated and that the request 
should include destinationUris.  But when submitting a job through the PHP API 
that only includes destinationUris, an error is returned: (400) Required 
parameter is missing.

Original issue reported on code.google.com by rolandan...@gmail.com on 14 Mar 2016 at 2:56

GoogleCodeExporter commented 8 years ago
Hmm, I was able to insert an extract job using the API explorer with only 
destinationUris specified and not destinationUri.  When calling from PHP, are 
you sure you have specified all required parameters, and that the parameters 
you've specified are not misspelled?  You should only need to specify 
sourceTable (and its three subfields) and one of destinationUri/destinationUris.

If you need further help, posting your client code or the HTTP requests that 
your client is making would help with further debugging.

BTW, this is the API explorer request that worked for me (anonymized):

POST 
https://www.googleapis.com/bigquery/v2/projects/<project>/jobs?key={YOUR_API_KEY
}

{
 "configuration": {
  "extract": {
   "destinationUris": [
    "gs://<URI>"
   ],
   "sourceTable": {
    "datasetId": "<dataset>",
    "projectId": "<project>",
    "tableId": "<table>"
   }
  }
 }
}

Original comment by dk...@google.com on 15 Mar 2016 at 12:40

GoogleCodeExporter commented 8 years ago
Thanks for following up!

The API explorer does work correctly with either the destinationUri or
destinationUris field set.  However, when calling from PHP, I've specified
the below.  If I only specify destinationUris, and exclude the
setDestinationUri line, it results in an error:

      $job = new Google_Service_Bigquery_Job();
      $job_config = new Google_Service_Bigquery_JobConfiguration();
      $extract_config = new
Google_Service_Bigquery_JobConfigurationExtract();
      $sourceTable = new Google_Service_Bigquery_TableReference();
      $sourceTable->setDatasetId($dataset_id);
      $sourceTable->setProjectId($project_id);
      $sourceTable->setTableId($table_id);
      $extract_config->setSourceTable($sourceTable);
      $extract_config->setDestinationUri($destination_uri);  // without
this line it results in an error, even though GBQ API Explorer says this is
deprecated
      $extract_config->setDestinationUris($destination_uri);

      $job_config->setExtract($extract_config);
      $job->setConfiguration($job_config);

      $job_r = $this->_gbq_service->jobs->insert($this->_project_id, $job);

Does setDestinationUris need be be provided a particular datatype?  I
wasn't able to discover what datatype by looking at the API code for class
Google_Service_Bigquery_JobConfigurationExtract in
google-api-php-client-x.x.x/src/Google/Service/Bigquery.php

Original comment by rolandan...@gmail.com on 17 Mar 2016 at 9:01

GoogleCodeExporter commented 8 years ago
Looking at Bigquery.php, yeah, it's completely non-obvious what type any of the 
fields should be.  Based on our API though, destinationUris should be an array 
of URIs (whereas destinationUri should just be a string).  Could you try 
wrapping your URI string in an array when passing it to setDestinationUris?  
It's possible that if the type of the field is wrong, our API is just dropping 
the field on the floor and ignoring it, leading to the error message you're 
seeing.

Original comment by dk...@google.com on 17 Mar 2016 at 9:05

GoogleCodeExporter commented 8 years ago
It looks like that does indeed work.  It's intuitive that the variable
should be an array from the field name and the API Explorer.  On the other
hand, a helpful hint in the error response that the provided input should
be an array would be helpful, to me at least.  More so than "required
parameter missing"- since the parameter was provided, just not as an array.

Thanks for a great product!

Original comment by rolandan...@gmail.com on 18 Mar 2016 at 9:20

GoogleCodeExporter commented 8 years ago
I agree that the behavior here is less than ideal.  You're not the first 
customer to hit that generic and unuseful error message.  We have plans to 
improve our API field parsing in a future revision, and hopefully that will 
improve the experience here.

Closing this out.

Original comment by dk...@google.com on 18 Mar 2016 at 9:30