{"record":{"id":"563775568df3d5b2","repo":"apache/beam","slug":"expected-a-table-reference-project-dataset-table-or-dataset","errorCode":null,"errorMessage":"Expected a table reference (PROJECT:DATASET.TABLE or DATASET.TABLE) instead of %s.","messagePattern":"Expected a table reference \\(PROJECT:DATASET\\.TABLE or DATASET\\.TABLE\\) instead of (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/gcp/bigquery_tools.py","lineNumber":293,"sourceCode":"        projectId=table.projectId,\n        datasetId=table.datasetId,\n        tableId=table.tableId)\n  elif callable(table):\n    return table\n  elif isinstance(table, value_provider.ValueProvider):\n    return table\n\n  table_reference = TableReference()\n  # If dataset argument is not specified, the expectation is that the\n  # table argument will contain a full table reference instead of just a\n  # table name.\n  if dataset is None:\n    pattern = (\n        f'((?P<project>{_PROJECT_PATTERN})[:\\\\.])?'\n        f'(?P<dataset>{_DATASET_PATTERN})\\\\.(?P<table>{_TABLE_PATTERN})')\n    match = regex.fullmatch(pattern, table)\n    if not match:\n      raise ValueError(\n          'Expected a table reference (PROJECT:DATASET.TABLE or '\n          'DATASET.TABLE) instead of %s.' % table)\n    table_reference.projectId = match.group('project')\n    table_reference.datasetId = match.group('dataset')\n    table_reference.tableId = match.group('table')\n  else:\n    table_reference.projectId = project\n    table_reference.datasetId = dataset\n    table_reference.tableId = table\n  return table_reference\n\n\n# -----------------------------------------------------------------------------\n# BigQueryWrapper.\n\n\ndef _build_job_labels(input_labels):\n  \"\"\"Builds job label protobuf structure.\"\"\"","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/gcp/bigquery_tools.py#L275-L311","documentation":"Raised by parse_table_reference when the table string does not fullmatch the pattern (optional PROJECT: then DATASET.TABLE, where DATASET may itself contain a project-qualified form). Beam cannot split the string into projectId/datasetId/tableId and refuses to build a TableReference.","triggerScenarios":"Passing strings like 'mytable' (no dataset), 'project:table' (no dataset), 'a.b.c.d' (too many parts), or strings with invalid characters/spaces to bigquery_io.parse_table_reference or APIs that call it (e.g. temp table resolution in BigQuerySink).","commonSituations":"Omitting the dataset when only a table name is known; using ':' instead of '.' between dataset and table; URI-encoded or whitespace-polluted table IDs from config files; accidentally passing a full BQ console URL instead of the table spec.","solutions":["Format the string as 'PROJECT:DATASET.TABLE' or at minimum 'DATASET.TABLE'.","Strip whitespace/quotes from the value before passing it.","If project is implied, use 'DATASET.TABLE' and let Beam fill the default project.","Alternatively construct a TableReference programmatically (bigquery.TableReference) instead of parsing a string."],"exampleFix":"// before\nparse_table_reference('mytable')\n\n// after\nparse_table_reference('my_project:my_dataset.mytable')","handlingStrategy":"validation","validationCode":"import re\n_PATTERN = re.compile(r'((?P<project>[a-z0-9_.\\-]+)[:\\.])?(?P<dataset>[a-zA-Z0-9_]+)\\.(?P<table>[a-zA-Z0-9_]+)$')\ndef validate_table_spec(s):\n    if not _PATTERN.fullmatch(s.strip()):\n        raise ValueError(f\"table ref {s!r} must be PROJECT:DATASET.TABLE or DATASET.TABLE\")","typeGuard":"def is_valid_table_reference(s):\n    parts = s.strip().split('.')\n    return len(parts) in (2, 3) and all(parts)","tryCatchPattern":"try:\n    ref = parse_table_reference(table_spec)\nexcept ValueError as e:\n    raise PipelineConfigError(f\"bad table spec {table_spec!r}; use PROJECT:DATASET.TABLE\") from e","preventionTips":["Build table specs from components: f'{project}:{dataset}.{table}'","Strip whitespace/quotes from config values","Never paste console URLs as table references"],"tags":["bigquery","table-reference","format","python"],"backgroundTag":"invalid-argument-format","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"}