I am trying to create a job in GoogleBigQuery
, that returns a JobId
instantly whilst the Job
continues to run without making the user wait.
From reading the documentation runQuery
suggests this should be possible. maxRetries
has been set as well as a very small timeoutMs
.
The idea being that the user will get a JobId
and an alert notifying them the Job
is being processed and they will receive a further notification when it's complete.
Installed via Composer Version: google/cloud: ^0.53.0
Sample code included below.
runQuery
Runs a BigQuery SQL query in a synchronous fashion.
Unless $options.maxRetries is specified, this method will block until the query completes, at which time the result set will be returned.
$client = new BigQueryClient([
'projectId' => 'XXXX',
]);
$client->dataset('XXXX');
if (!$dataset->exists()) {
throw new \Exception(sprintf('Dataset does not exist'));
}
$options = [
'timeoutMs' => 1000,
'maxRetries' => 2,
];
$queryJob = $client->queryConfig($sql, $options); //tried options here
$queryResult = $client->runQuery($queryJob,$options); //and tried options here together and individually
echo $queryResult->job()->id();