{"record":{"id":"1fc0659bd4f0c4d0","repo":"apache/beam","slug":"make-sure-the-values-passed-in-where-clause-fields-are-the","errorCode":null,"errorMessage":"Make sure the values passed in `where_clause_fields` are the keys in the input `beam.Row`.","messagePattern":"Make sure the values passed in `where_clause_fields` are the keys in the input `beam\\.Row`\\.","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":586,"sourceCode":"\n    Raises:\n      KeyError: If required fields are missing from the request\n    \"\"\"\n    try:\n      if isinstance(self._query_config, TableFunctionQueryConfig):\n        return [\n            val for val in self._query_config.where_clause_value_fn(request)\n        ]\n      elif isinstance(self._query_config, TableFieldsQueryConfig):\n        request_dict = request._asdict()\n        return [\n            request_dict[field]\n            for field in self._query_config.where_clause_fields\n        ]\n      else:\n        raise ValueError(\"Unsupported query configuration type\")\n    except KeyError as e:\n      raise KeyError(\n          \"Make sure the values passed in `where_clause_fields` are \"\n          \"the keys in the input `beam.Row`.\" + str(e))\n\n  def _extract_parameter_names(self, template: str) -> list[str]:\n    \"\"\"Extract parameter names from a SQL template string.\n\n    Args:\n      template: SQL template string with named parameters (e.g., \"id = :id\")\n\n    Returns:\n      List of parameter names found in the template (e.g., [\"id\"])\n    \"\"\"\n    return re.findall(r':(\\w+)', template)\n\n  def create_row_key(self, row: beam.Row):\n    if isinstance(self._query_config, TableFunctionQueryConfig):\n      return tuple(self._query_config.where_clause_value_fn(row))\n    if isinstance(self._query_config, TableFieldsQueryConfig):","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L568-L604","documentation":"For table-based query configs, _extract_values_from_request indexes request_dict[field] for each field in where_clause_fields; a KeyError is caught and re-raised with a message stating that every name in where_clause_fields must be a key of the input beam.Row (the missing key name is appended).","triggerScenarios":"A beam.Row missing one of the fields listed in where_clause_fields: typo, wrong case, field only present on some records, or an optional field not always emitted.","commonSituations":"Upstream DoFn emits rows with differing schemas; renaming a column in the pipeline without updating where_clause_fields; PCollection rows built with different dict keys per branch.","solutions":["Ensure every beam.Row contains all where_clause_fields keys before enrichment.","Fix typos/case mismatches between row keys and where_clause_fields.","Use the appended missing key name in the message to pinpoint the field."],"exampleFix":"# before (where_clause_fields=[\"id\"])\nrow = beam.Row(user_id=42)\n# after\nrow = beam.Row(id=42)","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["python","cloudsql","apache-beam","schema"],"backgroundTag":"missing-required-argument","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"}