{"record":{"id":"eb59f2954fd56c92","repo":"apache/beam","slug":"tablefunctionqueryconfig-must-provide-table-id-and-where","errorCode":null,"errorMessage":"TableFunctionQueryConfig must provide table_id and where_clause_template","messagePattern":"TableFunctionQueryConfig must provide table_id and where_clause_template","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py","lineNumber":83,"sourceCode":"          \"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:\n      raise ValueError(\n          \"TableFunctionQueryConfig must provide \" + \"where_clause_value_fn\")\n\n\nclass DatabaseTypeAdapter(Enum):\n  POSTGRESQL = \"pg8000\"\n  MYSQL = \"pymysql\"\n  SQLSERVER = \"pytds\"\n\n  def to_sqlalchemy_dialect(self):\n    \"\"\"Map the adapter type to its corresponding SQLAlchemy dialect.\n\n    Returns:\n        str: SQLAlchemy dialect string.","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/cloudsql.py#L65-L101","documentation":"TableFunctionQueryConfig.__post_init__ requires table_id and where_clause_template; missing or empty values raise ValueError. This config combines a table with a custom condition-value function, so both the table name and the SQL template are mandatory.","triggerScenarios":"TableFunctionQueryConfig(table_id=None/'' or where_clause_template=None/'', where_clause_value_fn=fn).","commonSituations":"Migrating from TableFieldsQueryConfig and dropping required fields; template strings loaded from config that resolve to empty.","solutions":["Supply non-empty table_id and where_clause_template strings","Check the code path that builds the config for accidental None assignment","Use CustomQueryConfig for full control instead of table+template"],"exampleFix":"// before\nTableFunctionQueryConfig(table_id='', where_clause_template='', where_clause_value_fn=fn)\n// after\nTableFunctionQueryConfig(table_id='orders', where_clause_template='WHERE order_id = :order_id', where_clause_value_fn=fn)","handlingStrategy":"validation","validationCode":"def make_table_fn_config(table_id, tmpl, fn):\n    if not table_id or not tmpl:\n        raise ValueError('table_id and where_clause_template required')\n    if not callable(fn):\n        raise ValueError('where_clause_value_fn must be callable')\n    return TableFunctionQueryConfig(table_id, tmpl, fn)","typeGuard":null,"tryCatchPattern":"try:\n    cfg = TableFunctionQueryConfig(**raw)\nexcept ValueError as e:\n    raise ValueError(f'invalid TableFunctionQueryConfig: {e}') from e","preventionTips":["Don't migrate between config variants by copy-paste; list required fields explicitly","Fail fast on empty template strings from config files","Test config construction in CI"],"tags":["python","apache-beam","cloudsql","dataclass","validation"],"backgroundTag":"missing-required-config-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"}