{"record":{"id":"273179eeef6db6b3","repo":"apache/beam","slug":"please-provide-either-query-fn-or-the-parameters-table-name","errorCode":null,"errorMessage":"Please provide either `query_fn` or the parameters `table_name`, `row_restriction_template`, and `fields/condition_value_fn` together.","messagePattern":"Please provide either `query_fn` or the parameters `table_name`, `row_restriction_template`, and `fields/condition_value_fn` together\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py","lineNumber":43,"sourceCode":"from google.api_core.exceptions import BadRequest\nfrom google.cloud import bigquery\n\nimport apache_beam as beam\nfrom apache_beam.pvalue import Row\nfrom apache_beam.transforms.enrichment import EnrichmentSourceHandler\n\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.","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py#L25-L61","documentation":"BigQueryEnrichmentHandler._validate_bigquery_metadata() rejects a configuration where query_fn is provided AND at least one of table_name, row_restriction_template, fields, or condition_value_fn is also given. The two configuration styles are mutually exclusive.","triggerScenarios":"Calling BigQueryEnrichmentHandler(query_fn=..., table_name='t') or query_fn plus row_restriction_template/fields/condition_value_fn.","commonSituations":"Migrating an existing handler from static-table config to a query_fn and leaving the old kwargs in place.","solutions":["Remove table_name, row_restriction_template, fields, and condition_value_fn when using query_fn","Or remove query_fn and configure the table-based path with table_name + row_restriction_template + (fields or condition_value_fn)"],"exampleFix":"// before\nBigQueryEnrichmentHandler(query_fn=my_fn, table_name='proj.ds.tbl')\n// after\nBigQueryEnrichmentHandler(query_fn=my_fn)","handlingStrategy":"validation","validationCode":"def check_bq_config(query_fn=None, table_name=None, row_restriction_template=None, fields=None, condition_value_fn=None):\n    if query_fn and (table_name or row_restriction_template or fields or condition_value_fn):\n        raise ValueError('query_fn is mutually exclusive with table-based params')","typeGuard":null,"tryCatchPattern":"try:\n    handler = BigQueryEnrichmentHandler(**cfg)\nexcept ValueError as e:\n    logger.error('Bad enrichment config: %s', e)\n    raise","preventionTips":["Pick one config style (query_fn OR table-based) per handler","Remove legacy kwargs when migrating to query_fn","Add a unit test constructing the handler with your exact kwargs"],"tags":["apache-beam","bigquery","configuration"],"backgroundTag":"mutually-exclusive-options","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"}