@@ -163,7 +163,13 @@ def _load_recording_runtime(calls: list[str]) -> SimpleNamespace:
163163 with a transient error, so retry behaviour is observable via ``calls``."""
164164
165165 def load_managed_table (
166- database : str , table : str , * , schema : str , upload_id : str , mode : str
166+ database : str ,
167+ table : str ,
168+ * ,
169+ schema : str ,
170+ upload_id : str ,
171+ mode : str ,
172+ key : list [str ] | None = None ,
167173 ) -> SimpleNamespace :
168174 calls .append (mode )
169175 raise TimeoutError ("commit succeeded but response was lost" )
@@ -209,3 +215,34 @@ def test_idempotent_load_retries_on_transient(monkeypatch: pytest.MonkeyPatch) -
209215 client .load_managed_table ("db" , "orders" , schema = "public" , upload_id = "u1" , mode = "replace" )
210216
211217 assert calls == ["replace" , "replace" , "replace" ] # retried up to max_retries
218+
219+
220+ def test_load_managed_table_forwards_key (monkeypatch : pytest .MonkeyPatch ) -> None :
221+ """A per-load ``key`` is passed straight through to the runtime client."""
222+ monkeypatch .setattr (mc .time , "sleep" , lambda _seconds : None )
223+ captured : dict [str , Any ] = {}
224+
225+ def load_managed_table (
226+ database : str ,
227+ table : str ,
228+ * ,
229+ schema : str ,
230+ upload_id : str ,
231+ mode : str ,
232+ key : list [str ] | None = None ,
233+ ) -> SimpleNamespace :
234+ captured ["mode" ] = mode
235+ captured ["key" ] = key
236+ return SimpleNamespace (
237+ connection_id = "c" , schema_name = schema , table_name = table , row_count = 0
238+ )
239+
240+ client = _managed_client (max_retries = 1 )
241+ runtime = _fake_runtime ()
242+ runtime .load_managed_table = load_managed_table
243+ client ._runtime = runtime
244+
245+ client .load_managed_table (
246+ "db" , "orders" , schema = "public" , upload_id = "u1" , mode = "delete" , key = ["id" ]
247+ )
248+ assert captured == {"mode" : "delete" , "key" : ["id" ]}
0 commit comments