File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -430,10 +430,11 @@ public function explainQuery($yql)
430430
431431 /**
432432 * @param string $yql
433+ * @param array $options
433434 * @return Statement
434435 * @throws Exception
435436 */
436- public function prepare ($ yql )
437+ public function prepare ($ yql, array $ options = [] )
437438 {
438439 $ statement = new Statement ($ this , $ yql );
439440
@@ -442,10 +443,24 @@ public function prepare($yql)
442443 return $ statement ;
443444 }
444445
445- $ result = $ this -> request ( ' PrepareDataQuery ' , [
446+ $ data = [
446447 'session_id ' => $ this ->session_id ,
447448 'yql_text ' => $ yql ,
448- ]);
449+ ];
450+
451+ // Add operation_timeout if specified
452+ if (isset ($ options ['operation_timeout_ms ' ])){
453+ $ operationParams = new OperationParams ();
454+ $ seconds = intdiv ( $ options ['operation_timeout_ms ' ], 1000 ); // get seconds
455+ $ nanos = fmod ($ options ['operation_timeout_ms ' ], 1000 ) * 1000000 ; // get ns
456+ $ operationParams ->setOperationTimeout (new Duration ([
457+ 'seconds ' => $ seconds ,
458+ 'nanos ' => $ nanos
459+ ]));
460+ $ data ['operation_params ' ] = $ operationParams ;
461+ }
462+
463+ $ result = $ this ->request ('PrepareDataQuery ' , $ data );
449464
450465 $ statement ->saveInCache ();
451466
You can’t perform that action at this time.
0 commit comments