{"record":{"id":"3ce727ef85ccd9b2","repo":"apache/beam","slug":"tablefieldsqueryconfig-must-provide-non-empty-where-clause","errorCode":null,"errorMessage":"TableFieldsQueryConfig must provide non-empty where_clause_fields","messagePattern":"TableFieldsQueryConfig must provide non-empty where_clause_fields","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":69,"sourceCode":"    if not self.query_fn:\n      raise ValueError(\"CustomQueryConfig must provide a valid query_fn\")\n\n\n@dataclass\nclass TableFieldsQueryConfig:\n  \"\"\"Configuration for using table name, where clause, and field names.\"\"\"\n  table_id: str\n  where_clause_template: str\n  where_clause_fields: list[str]\n\n  def __post_init__(self):\n    if not self.table_id or not self.where_clause_template:\n      raise ValueError(\n          \"TableFieldsQueryConfig must provide table_id and \" +\n          \"where_clause_template\")\n\n    if not self.where_clause_fields:\n      raise ValueError(\n          \"TableFieldsQueryConfig must provide non-empty \" +\n          \"where_clause_fields\")\n\n\n@dataclass\nclass TableFunctionQueryConfig:\n  \"\"\"Configuration for using table name, where clause, and a value function.\"\"\"\n  table_id: str\n  where_clause_template: str\n  where_clause_value_fn: ConditionValueFn\n\n  def __post_init__(self):\n    if not self.table_id or not self.where_clause_template:\n      raise ValueError(\n          \"TableFunctionQueryConfig must provide table_id and \" +\n          \"where_clause_template\")\n\n    if not self.where_clause_value_fn:","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L51-L87","documentation":"TableFieldsQueryConfig.__post_init__ also requires where_clause_fields to be non-empty, since the templated WHERE clause needs named fields to bind row values to query parameters. An empty list/None triggers this ValueError.","triggerScenarios":"TableFieldsQueryConfig(table_id='t', where_clause_template='WHERE id = :id', where_clause_fields=[]) or None.","commonSituations":"Declaring a WHERE template with placeholders but forgetting to list the corresponding fields; dynamically computed field lists that come back empty.","solutions":["Pass a non-empty list of field names matching the placeholders in where_clause_template","Ensure the fields exist on the enrichment input rows","Fall back to CustomQueryConfig if the query has no parameterized fields"],"exampleFix":"// before\nTableFieldsQueryConfig(table_id='users', where_clause_template='WHERE id = :id', where_clause_fields=[])\n// after\nTableFieldsQueryConfig(table_id='users', where_clause_template='WHERE id = :id', where_clause_fields=['id'])","handlingStrategy":"validation","validationCode":"def make_table_fields(table_id, tmpl, fields):\n    if not fields or not isinstance(fields, list):\n        raise ValueError('where_clause_fields must be a non-empty list')\n    return TableFieldsQueryConfig(table_id, tmpl, fields)","typeGuard":null,"tryCatchPattern":"try:\n    cfg = TableFieldsQueryConfig(**raw)\nexcept ValueError as e:\n    raise ValueError('where_clause_fields must be non-empty') from e","preventionTips":["Ensure every :placeholder in the template has a matching field entry","Validate that listed fields exist on input rows","Avoid dynamically derived field lists that can silently be empty"],"tags":["python","apache-beam","cloudsql","dataclass","validation"],"backgroundTag":"empty-required-field","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"}