{"record":{"id":"4beaf7f4a3b6c0b4","repo":"apache/beam","slug":"could-not-complete-the-query-request-query-e","errorCode":null,"errorMessage":"Could not complete the query request: {query}. {e}","messagePattern":"Could not complete the query request: (.+?)\\. (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py","lineNumber":187,"sourceCode":"    self.client = bigquery.Client(project=self.project, **self.kwargs)\n\n  def _execute_query(self, query: str):\n    try:\n      results = self.client.query(query=query).result()\n      row_list = [dict(row.items()) for row in results]\n      if not row_list:\n        return None\n      if self._batching_kwargs:\n        return row_list\n      else:\n        return row_list[0]\n    except BadRequest as e:\n      raise BadRequest(\n          f'Could not execute the query: {query}. Please check if '\n          f'the query is properly formatted and the BigQuery '\n          f'table exists. {e}')\n    except RuntimeError as e:\n      raise RuntimeError(f\"Could not complete the query request: {query}. {e}\")\n\n  def create_row_key(self, row: beam.Row):\n    if self.condition_value_fn:\n      return tuple(self.condition_value_fn(row))\n    if self.fields:\n      row_dict = row._asdict()\n      return (tuple(row_dict[field] for field in self.fields))\n    raise ValueError(\"Either fields or condition_value_fn must be specified\")\n\n  def __call__(self, request: Union[beam.Row, list[beam.Row]], *args, **kwargs):\n    if isinstance(request, list):\n      values = []\n      responses = []\n      requests_map: dict[Any, list[beam.Row]] = defaultdict(list)\n      batch_size = len(request)\n      raw_query = self.query_template\n      if batch_size > 1:\n        batched_condition_template = ' or '.join(","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py#L169-L205","documentation":"_execute_query() wraps RuntimeError from the BigQuery client's query-and-result call, re-raising with the query text. This indicates the query request could not be completed (client/runtime failure), distinct from a BadRequest (malformed query).","triggerScenarios":"The BigQuery client raises RuntimeError during query execution — e.g. request interrupted, client-side runtime failure in query_and_results — propagating through __call__.","commonSituations":"Transient BigQuery client failures, job timeouts surfacing as RuntimeError, misconfigured client/session.","solutions":["Retry the enrichment (the error is often transient)","Check job logs in BigQuery console for the underlying cause","Verify BigQuery client configuration/credentials and network access","Catch RuntimeError and apply a fallback enrichment strategy"],"exampleFix":"// before\nresult = handler(row)\n// after\ntry:\n    result = handler(row)\nexcept RuntimeError:\n    result = fallback_lookup(row)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    out = handler(row)\nexcept RuntimeError as e:\n    logger.warning('Transient BigQuery failure, retrying: %s', e)\n    out = retry(lambda: handler(row), attempts=3)","preventionTips":["Wrap enrichment calls with bounded retries for transient runtime failures","Monitor BigQuery job logs for systemic causes","Keep BigQuery client credentials/session configuration healthy"],"tags":["apache-beam","bigquery","runtime"],"backgroundTag":"database-query-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}