{"record":{"id":"bbbe24780de21135","repo":"apache/beam","slug":"please-provide-either-query-fn-or-the-parameters-table-name-bbbe24","errorCode":null,"errorMessage":"Please provide either `query_fn` or the parameters `table_name`, `row_restriction_template` together.","messagePattern":"Please provide either `query_fn` or the parameters `table_name`, `row_restriction_template` together\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py","lineNumber":49,"sourceCode":"\nQueryFn = Callable[[beam.Row], str]\nConditionValueFn = Callable[[beam.Row], list[Any]]\n\n_LOGGER = logging.getLogger(__name__)\n\n\ndef _validate_bigquery_metadata(\n    table_name, row_restriction_template, fields, condition_value_fn, query_fn):\n  if query_fn:\n    if bool(table_name or row_restriction_template or fields or\n            condition_value_fn):\n      raise ValueError(\n          \"Please provide either `query_fn` or the parameters `table_name`, \"\n          \"`row_restriction_template`, and `fields/condition_value_fn` \"\n          \"together.\")\n  else:\n    if not (table_name and row_restriction_template):\n      raise ValueError(\n          \"Please provide either `query_fn` or the parameters \"\n          \"`table_name`, `row_restriction_template` together.\")\n    if ((fields and condition_value_fn) or\n        (not fields and not condition_value_fn)):\n      raise ValueError(\n          \"Please provide exactly one of `fields` or \"\n          \"`condition_value_fn`\")\n\n\nclass BigQueryEnrichmentHandler(EnrichmentSourceHandler[Union[Row, list[Row]],\n                                                        Union[Row, list[Row]]]):\n  \"\"\"Enrichment handler for Google Cloud BigQuery.\n\n  Use this handler with :class:`apache_beam.transforms.enrichment.Enrichment`\n  transform.\n\n  To use this handler you need either of the following combinations:\n    * `table_name`, `row_restriction_template`, `fields`","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py#L31-L67","documentation":"_validate_bigquery_metadata() requires that, when no query_fn is given, both table_name and row_restriction_template are provided. If either is missing (None), this ValueError is raised from __init__.","triggerScenarios":"BigQueryEnrichmentHandler(table_name='t') without row_restriction_template, or with only fields/condition_value_fn and no table_name/template, and no query_fn.","commonSituations":"Forgot row_restriction_template (WHERE-clause template) when switching from query_fn to table-based enrichment; typo in kwarg name.","solutions":["Provide both table_name and row_restriction_template","Or provide a query_fn instead of the table-based parameters"],"exampleFix":"// before\nBigQueryEnrichmentHandler(table_name='proj.ds.tbl')\n// after\nBigQueryEnrichmentHandler(table_name='proj.ds.tbl', row_restriction_template='id = {id}')","handlingStrategy":"validation","validationCode":"def check_table_config(cfg):\n    if not cfg.get('query_fn'):\n        missing = [k for k in ('table_name', 'row_restriction_template') if not cfg.get(k)]\n        if missing:\n            raise ValueError(f'Missing required enrichment params: {missing}')","typeGuard":null,"tryCatchPattern":"try:\n    handler = BigQueryEnrichmentHandler(**cfg)\nexcept ValueError as e:\n    logger.error('Incomplete BigQuery enrichment config: %s', e)\n    raise","preventionTips":["Always set both table_name and row_restriction_template for table-based enrichment","Use keyword arguments with explicit names to avoid typo'd kwargs being ignored","Validate config at pipeline-construction time with a smoke instantiation"],"tags":["apache-beam","bigquery","missing-argument"],"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"}