allanminium
allanminium

Reputation: 139

Google BigQuery Catchable fatal error: Argument 2 passed

I'm currently using PHP with Google BigQuery and getting the following error -

Catchable fatal error: Argument 2 passed to Google_Service_Bigquery_Jobs_Resource::query() must be an instance of Google_Service_Bigquery_QueryRequest, none given, called in /a/a/a.com/a/a/a.php on line 34 and defined in /a/a/a.com/a/a/google-api-php-client/src/Google/Service/Bigquery.php on line 722

Here is the code surrounding it -

$service = new Google_Service_Bigquery($client);
$results = $service->jobs->query('SELECT * FROM [table.table] LIMIT 50'); // line 34

Never worked with Google BigQuery before so I'm not sure what I'm doing wrong here

Upvotes: 3

Views: 202

Answers (1)

Pentium10
Pentium10

Reputation: 208042

As the error says you need to pass Google_Service_Bigquery_QueryRequest object and not a string as 2nd parameter.

$query = new Google_Service_Bigquery_QueryRequest(); 
$sql = "SELECT account_number, customer_name, FROM [mydatabase] ORDER BY sales_value DESC, sales_value DESC, sales_value DESC LIMIT 10"; 
$query->setQuery($sql); 
$response = $service->jobs->query($project_id, $query); 
echo json_encode($response);

More at: http://vcert.blogspot.ro/2014/06/integrating-googles-bigquery-into-your.html

Upvotes: 3

Related Questions