{"record":{"id":"c71c91129192c5fa","repo":"apache/beam","slug":"no-matching-row-found-for-query-query","errorCode":null,"errorMessage":"no matching row found for query: {query}","messagePattern":"no matching row found for query: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py","lineNumber":237,"sourceCode":"        values.extend(current_values)\n        requests_map[self.create_row_key(req)].append(req)\n      query = raw_query.format(*values)\n\n      responses_dict = self._execute_query(query)\n      unmatched_requests = {\n          key: list(reqs)\n          for key, reqs in requests_map.items()\n      }\n      if responses_dict:\n        for response in responses_dict:\n          response_row = beam.Row(**response)\n          response_key = self.create_row_key(response_row)\n          if response_key in unmatched_requests:\n            for req in unmatched_requests.pop(response_key):\n              responses.append((req, response_row))\n      if unmatched_requests:\n        if self.throw_exception_on_empty_results:\n          raise ValueError(f\"no matching row found for query: {query}\")\n        else:\n          _LOGGER.warning('no matching row found for query: %s', query)\n          for reqs in unmatched_requests.values():\n            for req in reqs:\n              responses.append((req, beam.Row()))\n      return responses\n    else:\n      request_dict = request._asdict()\n      if self.query_fn:\n        # if a query_fn is provided then it return a list of values\n        # that should be populated into the query template string.\n        query = self.query_fn(request)\n      else:\n        values = (\n            self.condition_value_fn(request) if self.condition_value_fn else\n            list(map(request_dict.get, self.fields)))\n        # construct the query.\n        query = self.query_template.format(*values)","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py#L219-L255","documentation":"In the batched __call__ path, after executing the query, requests that got no matching BigQuery row remain unmatched. If throw_exception_on_empty_results is True, a ValueError naming the query is raised; otherwise a warning is logged and empty rows are returned.","triggerScenarios":"Batched call where none of the returned BigQuery rows match the keys of the submitted requests (keys don't join), with throw_exception_on_empty_results=True.","commonSituations":"Type mismatch between the enrichment-table key and the input key (int vs string); row_restriction_template filtering out all rows; data genuinely missing in the table.","solutions":["Set throw_exception_on_empty_results=False if empty results are acceptable (warning + empty Row returned instead)","Verify key types match between input rows and the BigQuery table (e.g. cast id to STRING)","Check the row_restriction_template/query filters aren't excluding valid rows","Confirm the lookup values exist in the table"],"exampleFix":"// before\nBigQueryEnrichmentHandler(..., throw_exception_on_empty_results=True)\n// after\nBigQueryEnrichmentHandler(..., throw_exception_on_empty_results=False)","handlingStrategy":"fallback","validationCode":"def normalize_key(v):\n    return str(v).strip()\n# ensure both sides of the join use the same normalization before enrichment","typeGuard":null,"tryCatchPattern":"try:\n    out = handler(rows)\nexcept ValueError as e:\n    if 'no matching row' in str(e):\n        out = [(r, beam.Row()) for r in rows]\n    else:\n        raise","preventionTips":["Match key types between input Rows and the BigQuery table (cast int/str consistently)","Set throw_exception_on_empty_results=False when missing matches are business-as-usual","Keep row_restriction_template filters permissive enough for legitimate rows"],"tags":["apache-beam","bigquery","empty-result"],"backgroundTag":"record-not-found","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"}