{"record":{"id":"7765124d8db94649","repo":"apache/beam","slug":"the-method-to-read-from-bigquery-must-be-either-export-or","errorCode":null,"errorMessage":"The method to read from BigQuery must be either EXPORT or DIRECT_READ.","messagePattern":"The method to read from BigQuery must be either EXPORT or DIRECT_READ\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery.py","lineNumber":3100,"sourceCode":"            \"provide query_output_schema so the output schema can be \"\n            \"determined without reading an existing table. The schema should \"\n            \"be a BigQuery schema dict, e.g. \"\n            \"{'fields': [{'name': 'col', 'type': 'STRING', 'mode': 'NULLABLE'}\"\n            \", ...]}, or a TableSchema object.\")\n\n    self.gcs_location = gcs_location\n    self.bigquery_dataset_labels = {\n        'type': 'bq_direct_read_' + str(uuid.uuid4())[0:10]\n    }\n\n  def expand(self, pcoll):\n    if self.method == ReadFromBigQuery.Method.EXPORT:\n      output_pcollection = self._expand_export(pcoll)\n    elif self.method == ReadFromBigQuery.Method.DIRECT_READ:\n      output_pcollection = self._expand_direct_read(pcoll)\n\n    else:\n      raise ValueError(\n          'The method to read from BigQuery must be either EXPORT '\n          'or DIRECT_READ.')\n    return self._expand_output_type(output_pcollection)\n\n  def _expand_output_type(self, output_pcollection):\n    if self.output_type == 'PYTHON_DICT' or self.output_type is None:\n      return output_pcollection\n    elif self.output_type == 'BEAM_ROW':\n      if self._kwargs.get('query', None) is not None:\n        user_schema = bigquery_tools.get_dict_table_schema(\n            self.query_output_schema)\n        return output_pcollection | bigquery_schema_tools.convert_to_usertype(\n            user_schema, self._kwargs.get('selected_fields', None))\n      table_details = bigquery_tools.parse_table_reference(\n          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):","sourceCodeStart":3082,"sourceCodeEnd":3118,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery.py#L3082-L3118","documentation":"ReadFromBigQuery.expand dispatches on self.method and only supports ReadFromBigQuery.Method.EXPORT and Method.DIRECT_READ. A ValueError is raised (bigquery.py:3100) when method holds any other value, meaning the transform has no read implementation to run.","triggerScenarios":"Passing method='export' (wrong case/string instead of the enum), method=None explicitly, a custom string, or an enum from a differently-versioned Beam where the value is not one of the two supported members.","commonSituations":"Treating method as a free-form string instead of ReadFromBigQuery.Method; typos like Method.Export; constructing the transform programmatically with a variable that is None; pickled configs from older Beam versions.","solutions":["Set method=ReadFromBigQuery.Method.EXPORT or ReadFromBigQuery.Method.DIRECT_READ","Do not pass a raw string; import the Method enum from ReadFromBigQuery","Print ReadFromBigQuery.Method.__members__ to confirm valid values in your Beam version"],"exampleFix":"// before\nReadFromBigQuery(table=t, method='EXPORT')\n// after\nReadFromBigQuery(table=t, method=ReadFromBigQuery.Method.EXPORT)","handlingStrategy":"validation","validationCode":"assert method in (ReadFromBigQuery.Method.EXPORT, ReadFromBigQuery.Method.DIRECT_READ), method","typeGuard":"def is_valid_method(m):\n    return m in (ReadFromBigQuery.Method.EXPORT, ReadFromBigQuery.Method.DIRECT_READ)","tryCatchPattern":"try:\n    result = pcoll | ReadFromBigQuery(method=method, ...)\nexcept ValueError as e:\n    if 'EXPORT or DIRECT_READ' in str(e):\n        method = ReadFromBigQuery.Method.EXPORT","preventionTips":["Always use the ReadFromBigQuery.Method enum, never raw strings","Pin your Beam version and check enum members after upgrades","Centralize transform construction to validate options once"],"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"}