So I tried running a query with dryRun set to true and I got a 404 Not Found Error.
My Code
$sql = "<Some Simple SQL>";
$options = ['maxResults' => 10, 'startIndex' => 0];
$jobConfig = $client->query($sql)->dryRun(true);
$results = $client->runQuery($jobConfig, $options);
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not found: Job <my-job-id>"
}
],
"code": 404,
"message": "Not found: Job <my-job-id>"
}
}
Am I doing something wrong here?
All I'm trying to do is mimic the following with this API.
https://cloud.google.com/bigquery/docs/best-practices-costs#performing_a_dry_run
Thank you for the report @taka-oyama. The method which will allow you to look up dry run related bits of data (such as projected total bytes processed) will be BigQueryClient::startQuery(). The issue with runQuery is that it attempts to fetch rows for you automatically, even though they do not exist for a dry run scenario.
To help make this clearer, I will add some documentation regarding where dry run can be used and have runQuery throw an exception if a dry run is configured.
Thank you. startQuery() works as expected!