{"record":{"id":"c467b0db45144cf5","repo":"apache/beam","slug":"a-bigquery-table-or-a-query-must-be-specified","errorCode":null,"errorMessage":"A BigQuery table or a query must be specified","messagePattern":"A BigQuery table or a query must be specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":725,"sourceCode":"      validate=False,\n      pipeline_options=None,\n      coder=None,\n      use_standard_sql=False,\n      flatten_results=True,\n      kms_key=None,\n      bigquery_job_labels=None,\n      use_json_exports=False,\n      job_name=None,\n      step_name=None,\n      unique_id=None,\n      temp_dataset=None,\n      query_priority=BigQueryQueryPriority.BATCH):\n    if table is not None and query is not None:\n      raise ValueError(\n          'Both a BigQuery table and a query were specified.'\n          ' Please specify only one of these.')\n    elif table is None and query is None:\n      raise ValueError('A BigQuery table or a query must be specified')\n    elif table is not None:\n      self.table_reference = bigquery_tools.parse_table_reference(\n          table, dataset, project)\n      self.query = None\n      self.use_legacy_sql = True\n    else:\n      if isinstance(query, str):\n        query = StaticValueProvider(str, query)\n      self.query = query\n      # TODO(BEAM-1082): Change the internal flag to be standard_sql\n      self.use_legacy_sql = not use_standard_sql\n      self.table_reference = None\n\n    self.method = method\n    self.gcs_location = gcs_location\n    self.project = project\n    self.validate = validate\n    self.flatten_results = flatten_results","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L707-L743","documentation":"Validation guard in BigQuerySource.__init__ (the legacy batch BigQuery source): the source must know where to read from, either a table reference or a SQL query, and neither was provided. It fires when callers construct the source directly (or via Read(BigQuerySource(...))) leaving both `table` and `query` as None, typically when options are built dynamically and the argument is dropped. Note the sibling check on the same lines rejects specifying both at once.","triggerScenarios":"Constructing BigQuerySource() or ReadFromBigQuery() with neither table nor query (or both explicitly None).","commonSituations":"Config placeholders left empty (empty strings coerced to None), environment variables missing so table names resolve to None.","solutions":["Provide a table: ReadFromBigQuery(table='project:dataset.table')","Or provide a query: ReadFromBigQuery(query='SELECT ...')","Check that config/env values feeding these arguments are actually set and non-empty"],"exampleFix":"// before\nsource = BigQuerySource(table=None, query=None)\n// after\nsource = BigQuerySource(table='my-project:my_dataset.my_table')","handlingStrategy":"validation","validationCode":"if table is None and query is None:\n    raise ValueError('A BigQuery table or a query must be specified')","typeGuard":"def has_source(table, query):\n    return table is not None or query is not None","tryCatchPattern":"try:\n    source = BigQuerySource(table=table, query=query)\nexcept ValueError as e:\n    if 'must be specified' in str(e):\n        table = os.environ['BIGQUERY_TABLE']\n        source = BigQuerySource(table=table, query=query)\n    else:\n        raise","preventionTips":["Fail fast on missing/empty table or query config at pipeline startup","Avoid coercing empty strings to falsy values silently","Require the source option in pipeline option parsing (--table/--query)"],"tags":["python","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-14T11:17:12.474Z"}