5858 TransactionOptions ,
5959)
6060from google .cloud .spanner_v1 .table import Table
61+ from google .cloud .spanner_v1 import RequestOptions
6162
6263# pylint: enable=ungrouped-imports
6364
64-
6565SPANNER_DATA_SCOPE = "https://www.googleapis.com/auth/spanner.data"
6666
6767
@@ -454,7 +454,12 @@ def drop(self):
454454 api .drop_database (database = self .name , metadata = metadata )
455455
456456 def execute_partitioned_dml (
457- self , dml , params = None , param_types = None , query_options = None
457+ self ,
458+ dml ,
459+ params = None ,
460+ param_types = None ,
461+ query_options = None ,
462+ request_options = None ,
458463 ):
459464 """Execute a partitionable DML statement.
460465
@@ -478,12 +483,22 @@ def execute_partitioned_dml(
478483 If a dict is provided, it must be of the same form as the protobuf
479484 message :class:`~google.cloud.spanner_v1.types.QueryOptions`
480485
486+ :type request_options:
487+ :class:`google.cloud.spanner_v1.types.RequestOptions`
488+ :param request_options:
489+ (Optional) Common options for this request.
490+ If a dict is provided, it must be of the same form as the protobuf
491+ message :class:`~google.cloud.spanner_v1.types.RequestOptions`.
492+
481493 :rtype: int
482494 :returns: Count of rows affected by the DML statement.
483495 """
484496 query_options = _merge_query_options (
485497 self ._instance ._client ._query_options , query_options
486498 )
499+ if type (request_options ) == dict :
500+ request_options = RequestOptions (request_options )
501+
487502 if params is not None :
488503 from google .cloud .spanner_v1 .transaction import Transaction
489504
@@ -517,6 +532,7 @@ def execute_pdml():
517532 params = params_pb ,
518533 param_types = param_types ,
519534 query_options = query_options ,
535+ request_options = request_options ,
520536 )
521537 method = functools .partial (
522538 api .execute_streaming_sql , metadata = metadata ,
@@ -561,16 +577,23 @@ def snapshot(self, **kw):
561577 """
562578 return SnapshotCheckout (self , ** kw )
563579
564- def batch (self ):
580+ def batch (self , request_options = None ):
565581 """Return an object which wraps a batch.
566582
567583 The wrapper *must* be used as a context manager, with the batch
568584 as the value returned by the wrapper.
569585
586+ :type request_options:
587+ :class:`google.cloud.spanner_v1.types.RequestOptions`
588+ :param request_options:
589+ (Optional) Common options for the commit request.
590+ If a dict is provided, it must be of the same form as the protobuf
591+ message :class:`~google.cloud.spanner_v1.types.RequestOptions`.
592+
570593 :rtype: :class:`~google.cloud.spanner_v1.database.BatchCheckout`
571594 :returns: new wrapper
572595 """
573- return BatchCheckout (self )
596+ return BatchCheckout (self , request_options )
574597
575598 def batch_snapshot (self , read_timestamp = None , exact_staleness = None ):
576599 """Return an object which wraps a batch read / query.
@@ -756,11 +779,19 @@ class BatchCheckout(object):
756779
757780 :type database: :class:`~google.cloud.spanner_v1.database.Database`
758781 :param database: database to use
782+
783+ :type request_options:
784+ :class:`google.cloud.spanner_v1.types.RequestOptions`
785+ :param request_options:
786+ (Optional) Common options for the commit request.
787+ If a dict is provided, it must be of the same form as the protobuf
788+ message :class:`~google.cloud.spanner_v1.types.RequestOptions`.
759789 """
760790
761- def __init__ (self , database ):
791+ def __init__ (self , database , request_options = None ):
762792 self ._database = database
763793 self ._session = self ._batch = None
794+ self ._request_options = request_options
764795
765796 def __enter__ (self ):
766797 """Begin ``with`` block."""
@@ -772,7 +803,10 @@ def __exit__(self, exc_type, exc_val, exc_tb):
772803 """End ``with`` block."""
773804 try :
774805 if exc_type is None :
775- self ._batch .commit (return_commit_stats = self ._database .log_commit_stats )
806+ self ._batch .commit (
807+ return_commit_stats = self ._database .log_commit_stats ,
808+ request_options = self ._request_options ,
809+ )
776810 finally :
777811 if self ._database .log_commit_stats and self ._batch .commit_stats :
778812 self ._database .logger .info (
0 commit comments