File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,13 @@ def _create_bigquery_client(self):
181
181
location = self ._location ,
182
182
)
183
183
184
+ # If a new enough client library is available, we opt-in to the faster
185
+ # backend behavior. This only affects code paths where query_and_wait is
186
+ # used, which doesn't expose a query job directly. See internal issue
187
+ # b/417985981.
188
+ if hasattr (bq_client , "default_job_creation_mode" ):
189
+ bq_client .default_job_creation_mode = "JOB_CREATION_OPTIONAL"
190
+
184
191
if self ._bq_kms_key_name :
185
192
# Note: Key configuration only applies automatically to load and query jobs, not copy jobs.
186
193
encryption_config = bigquery .EncryptionConfiguration (
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ def create_clients_provider(application_name: Optional[str] = None):
46
46
def monkeypatch_client_constructors (monkeypatch ):
47
47
bqclient = mock .create_autospec (google .cloud .bigquery .Client )
48
48
bqclient .return_value = bqclient
49
+ # Assume we have a new client library in the unit tests.
50
+ bqclient .default_job_creation_mode = None # type: ignore
49
51
monkeypatch .setattr (google .cloud .bigquery , "Client" , bqclient )
50
52
51
53
bqconnectionclient = mock .create_autospec (
@@ -83,6 +85,11 @@ def monkeypatch_client_constructors(monkeypatch):
83
85
)
84
86
85
87
88
+ def assert_bqclient_sets_default_job_creation_mode (provider : clients .ClientsProvider ):
89
+ bqclient = provider .bqclient
90
+ assert bqclient .default_job_creation_mode == "JOB_CREATION_OPTIONAL"
91
+
92
+
86
93
def assert_constructed_w_user_agent (mock_client : mock .Mock , expected_user_agent : str ):
87
94
assert (
88
95
expected_user_agent
You can’t perform that action at this time.
0 commit comments