{"record":{"id":"c4868c00cca4bc04","repo":"apache/beam","slug":"write-disposition-s-is-not-supported-for-streaming-inserts","errorCode":null,"errorMessage":"Write disposition %s is not supported for streaming inserts to BigQuery","messagePattern":"Write disposition (.+?) is not supported for streaming inserts to BigQuery","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":1546,"sourceCode":"        destination. If not, perform best-effort batching per destination within\n        a bundle.\n      ignore_unknown_columns: Accept rows that contain values that do not match\n        the schema. The unknown values are ignored. Default is False,\n        which treats unknown values as errors. See reference:\n        https://cloud.google.com/bigquery/docs/reference/rest/v2/tabledata/insertAll\n      max_retries: The number of times that we will retry inserting a group of\n        rows into BigQuery. By default, we retry 10000 times with exponential\n        backoffs (effectively retry forever).\n      max_insert_payload_size: The maximum byte size for a BigQuery legacy\n        streaming insert payload.\n    \"\"\"\n    self.schema = schema\n    self.test_client = test_client\n    self.create_disposition = create_disposition\n    self.write_disposition = write_disposition\n    if write_disposition in (BigQueryDisposition.WRITE_EMPTY,\n                             BigQueryDisposition.WRITE_TRUNCATE):\n      raise ValueError(\n          'Write disposition %s is not supported for'\n          ' streaming inserts to BigQuery' % write_disposition)\n    self._rows_buffer = []\n    self._reset_rows_buffer()\n\n    self._total_buffered_rows = 0\n    self.kms_key = kms_key\n    self._max_batch_size = batch_size or BigQueryWriteFn.DEFAULT_MAX_BATCH_SIZE\n    self._max_buffered_rows = (\n        max_buffered_rows or BigQueryWriteFn.DEFAULT_MAX_BUFFERED_ROWS)\n    self._retry_strategy = retry_strategy or RetryStrategy.RETRY_ALWAYS\n    self.ignore_insert_ids = ignore_insert_ids\n    self.with_batched_input = with_batched_input\n\n    self.additional_bq_parameters = additional_bq_parameters or {}\n\n    # accumulate the total time spent in exponential backoff\n    self._throttled_secs = Metrics.counter(","sourceCodeStart":1528,"sourceCodeEnd":1564,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L1528-L1564","documentation":"BigQueryWriteFn (STREAMING_INSERTS method) rejects write dispositions WRITE_EMPTY and WRITE_TRUNCATE. Those dispositions are table-level load/write semantics evaluated at job creation, which do not apply to per-row streaming inserts; only WRITE_APPEND makes sense for the streaming path, so the constructor raises ValueError.","triggerScenarios":"Constructing WriteToBigQuery(method=STREAMING_INSERTS, write_disposition=WRITE_TRUNCATE or WRITE_EMPTY) — including the default STREAMING_INSERTS path with an explicitly set non-append disposition.","commonSituations":"Reusing a config shared between file-load and streaming pipelines; switching a pipeline from FILE_LOADS to STREAMING_INSERTS while keeping write_disposition='WRITE_TRUNCATE'.","solutions":["Use write_disposition=BigQueryDisposition.WRITE_APPEND with STREAMING_INSERTS.","Switch the method to FILE_LOADS if you actually need WRITE_TRUNCATE/WRITE_EMPTY semantics.","Parameterize the disposition per method and validate before constructing the transform."],"exampleFix":"// before\nbeam.io.WriteToBigQuery(table, method='STREAMING_INSERTS', write_disposition='WRITE_TRUNCATE')\n// after\nbeam.io.WriteToBigQuery(table, method='STREAMING_INSERTS', write_disposition='WRITE_APPEND')","handlingStrategy":"validation","validationCode":"if method == WriteToBigQuery.Method.STREAMING_INSERTS and write_disposition in ('WRITE_EMPTY', 'WRITE_TRUNCATE'):\n    raise ValueError('streaming inserts require WRITE_APPEND')","typeGuard":"def streaming_disposition_ok(d):\n    return d in (None, BigQueryDisposition.WRITE_APPEND)","tryCatchPattern":"try:\n    _ = beam.io.WriteToBigQuery(table, method='STREAMING_INSERTS', write_disposition=disp)\nexcept ValueError as e:\n    logger.error('Invalid streaming write disposition: %s', e)","preventionTips":["Use WRITE_APPEND for streaming inserts","Keep separate configs for streaming and file-load pipelines","Centralize BigQuery writer construction with method-aware validation"],"tags":["bigquery","python","apache-beam","streaming-inserts"],"backgroundTag":"invalid-enum-value","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"}