{"record":{"id":"76591e4a3e65f5c1","repo":"apache/beam","slug":"both-a-bigquery-temp-dataset-id-and-a-temp-table-ref-were","errorCode":null,"errorMessage":"Both a BigQuery temp_dataset_id and a temp_table_ref were specified. Please specify only one of these.","messagePattern":"Both a BigQuery temp_dataset_id and a temp_table_ref were specified\\. Please specify only one of these\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery_tools.py","lineNumber":385,"sourceCode":"\n  def __init__(self, client=None, temp_dataset_id=None, temp_table_ref=None):\n    self.client = client or BigQueryWrapper._bigquery_client(PipelineOptions())\n    self.gcp_bq_client = client or gcp_bigquery.Client(\n        client_info=ClientInfo(\n            user_agent=\"apache-beam-%s\" % apache_beam.__version__))\n\n    self._unique_row_id = 0\n    # For testing scenarios where we pass in a client we do not want a\n    # randomized prefix for row IDs.\n    self._row_id_prefix = '' if client else uuid.uuid4()\n    self._latency_histogram_metric = Metrics.histogram(\n        self.__class__,\n        'latency_histogram_ms',\n        LinearBucket(0, 20, 3000),\n        BigQueryWrapper.HISTOGRAM_METRIC_LOGGER)\n\n    if temp_dataset_id is not None and temp_table_ref is not None:\n      raise ValueError(\n          'Both a BigQuery temp_dataset_id and a temp_table_ref were specified.'\n          ' Please specify only one of these.')\n\n    if temp_dataset_id and temp_dataset_id.startswith(self.TEMP_DATASET):\n      raise ValueError(\n          'User provided temp dataset ID cannot start with %r' %\n          self.TEMP_DATASET)\n\n    if temp_table_ref is not None:\n      self.temp_table_ref = temp_table_ref\n      self.temp_dataset_id = temp_table_ref.datasetId\n    else:\n      self.temp_table_ref = None\n      self._temporary_table_suffix = uuid.uuid4().hex\n      self.temp_dataset_id = temp_dataset_id or self._get_temp_dataset()\n\n    self.created_temp_dataset = False\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery_tools.py#L367-L403","documentation":"Raised in BigQueryWrapper.__init__ when both temp_dataset_id and temp_table_ref are supplied. A temp_table_ref already implies its dataset, so specifying both is ambiguous and Beam rejects the combination.","triggerScenarios":"Constructing BigQueryWrapper(temp_dataset_id='x', temp_table_ref=<TableReference>) directly, or via pipeline options where both --temp_dataset_id-style custom options and a temp table reference end up set.","commonSituations":"Migrating code from the temp_dataset_id option to temp_table_ref and leaving both configured; wiring wrapper kwargs from two config sources that both define temp locations.","solutions":["Remove temp_dataset_id and keep only temp_table_ref (the ref carries the dataset).","Or remove temp_table_ref and keep only temp_dataset_id if you just want a custom temp dataset.","Audit config/option plumbing so only one temp-location setting is populated.","Let Beam create its own temp dataset by passing neither argument."],"exampleFix":"// before\nBigQueryWrapper(temp_dataset_id='my_tmp_ds', temp_table_ref=ref)\n\n// after\nBigQueryWrapper(temp_table_ref=ref)","handlingStrategy":"validation","validationCode":"if temp_dataset_id and temp_table_ref:\n    raise ValueError('pass either temp_dataset_id or temp_table_ref, not both')","typeGuard":"def temp_options_are_consistent(opts):\n    return not (opts.get('temp_dataset_id') and opts.get('temp_table_ref'))","tryCatchPattern":"try:\n    wrapper = BigQueryWrapper(temp_dataset_id=ds, temp_table_ref=ref)\nexcept ValueError as e:\n    if 'only one of these' in str(e):\n        wrapper = BigQueryWrapper(temp_table_ref=ref)  # ref wins\n    else:\n        raise","preventionTips":["Choose one temp-location mechanism per pipeline and document it","When migrating from temp_dataset_id to temp_table_ref, delete the old option","Assert mutual exclusivity in pipeline option parsing"],"tags":["bigquery","conflicting-options","temp-dataset","python"],"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"}