{"record":{"id":"32fd6d48e4e93f8b","repo":"apache/beam","slug":"the-output-type-from-bigquery-must-be-either-python-dict-or","errorCode":null,"errorMessage":"The output type from BigQuery must be either PYTHON_DICT or BEAM_ROW.","messagePattern":"The output type from BigQuery must be either PYTHON_DICT or BEAM_ROW\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":3133,"sourceCode":"          table=self._kwargs.get(\"table\", None),\n          dataset=self._kwargs.get(\"dataset\", None),\n          project=self._kwargs.get(\"project\", None))\n      if isinstance(self._kwargs['table'], ValueProvider):\n        raise TypeError(\n            '%s: table must be of type string'\n            '; got ValueProvider instead' % self.__class__.__name__)\n      elif callable(self._kwargs['table']):\n        raise TypeError(\n            '%s: table must be of type string'\n            '; got a callable instead' % self.__class__.__name__)\n      return output_pcollection | bigquery_schema_tools.convert_to_usertype(\n          bigquery_tools.BigQueryWrapper().get_table(\n              project_id=table_details.projectId,\n              dataset_id=table_details.datasetId,\n              table_id=table_details.tableId).schema,\n          self._kwargs.get('selected_fields', None))\n    else:\n      raise ValueError(\n          'The output type from BigQuery must be either PYTHON_DICT '\n          'or BEAM_ROW.')\n\n  def _expand_export(self, pcoll):\n    # TODO(https://github.com/apache/beam/issues/20683): Make ReadFromBQ rely\n    # on ReadAllFromBQ implementation.\n    temp_location = pcoll.pipeline.options.view_as(\n        GoogleCloudOptions).temp_location\n    job_name = pcoll.pipeline.options.view_as(GoogleCloudOptions).job_name\n    gcs_location_vp = self.gcs_location\n    unique_id = str(uuid.uuid4())[0:10]\n\n    def file_path_to_remove(unused_elm):\n      gcs_location = bigquery_export_destination_uri(\n          gcs_location_vp, temp_location, unique_id, True)\n      return gcs_location + '/'\n\n    files_to_remove_pcoll = beam.pvalue.AsList(","sourceCodeStart":3115,"sourceCodeEnd":3151,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L3115-L3151","documentation":"_expand_output_type only implements output_type values 'PYTHON_DICT' and 'BEAM_ROW'; anything else falls into a final else that raises ValueError (bigquery.py:3133). The transform cannot map BigQuery rows to the requested output representation.","triggerScenarios":"ReadFromBigQuery(..., output_type='dict'), output_type='JSON', output_type='beam_row' (wrong case), or any string other than the two supported literals.","commonSituations":"Guessing at output_type values without reading the docs; case inconsistencies after refactors; older code using an output_type value removed in a newer Beam release.","solutions":["Set output_type='PYTHON_DICT' or output_type='BEAM_ROW' (exact strings)","Omit output_type entirely to get the default PYTHON_DICT behavior","Check the ReadFromBigQuery docs for your Beam version for supported values"],"exampleFix":"// before\nReadFromBigQuery(table=t, output_type='dict')\n// after\nReadFromBigQuery(table=t, output_type='PYTHON_DICT')","handlingStrategy":"validation","validationCode":"assert output_type in (None, 'PYTHON_DICT', 'BEAM_ROW'), output_type","typeGuard":"def is_valid_output_type(ot):\n    return ot in ('PYTHON_DICT', 'BEAM_ROW')","tryCatchPattern":"try:\n    t = ReadFromBigQuery(output_type=ot, ...)\nexcept ValueError as e:\n    if 'PYTHON_DICT or BEAM_ROW' in str(e):\n        ot = 'PYTHON_DICT'","preventionTips":["Use the exact documented literals (uppercase)","Omit output_type for default behavior","Grep your codebase for output_type after Beam upgrades"],"tags":["python","apache-beam","bigquery","invalid-enum"],"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"}