{"record":{"id":"c50f821e4951b09d","repo":"apache/beam","slug":"the-field-name-col-was-specified-more-than-once","errorCode":null,"errorMessage":"The field name \"{col}\" was specified more than once.","messagePattern":"The field name \"(.+?)\" was specified more than once\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/yaml/yaml_join.py","lineNumber":125,"sourceCode":"  return equalities\n\n\ndef _parse_fields(tables, fields):\n  error_prefix = f'Invalid value \"{fields}\" for \"fields\".'\n  if not isinstance(fields, dict):\n    raise ValueError(f'{error_prefix} Fields must be a dict.')\n  output_fields = []\n  named_columns = set()\n  for input, cols in fields.items():\n    if input not in tables:\n      raise ValueError(f'An invalid input \"{input}\" was specified in \"fields\".')\n    if isinstance(cols, list):\n      for col in cols:\n        if not isinstance(col, str):\n          raise ValueError(\n              f'Invalid column \"{col}\" in \"fields\". Column name must be a str.')\n        if col in named_columns:\n          raise ValueError(\n              f'The field name \"{col}\" was specified more than once.')\n        output_fields.append(f'{input}.{col} AS {col}')\n        named_columns.add(col)\n    elif isinstance(cols, dict):\n      for k, v in cols.items():\n        if k in named_columns:\n          raise ValueError(\n              f'The field name \"{k}\" was specified more than once.')\n        if not isinstance(v, str):\n          raise ValueError(\n              f'Invalid column \"{v}\" in \"fields\". Column name must be a str.')\n        output_fields.append(f'{input}.{v} AS {k}')\n        named_columns.add(k)\n    else:\n      raise ValueError(\n          f'{error_prefix} '\n          f'For every input key in fields, '\n          f'the value must either be a list or dict.')","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/yaml/yaml_join.py#L107-L143","documentation":"Output field names must be unique across the joined result. When a list-style columns entry names a column that has already been emitted by another input (tracked in named_columns), _parse_fields raises this duplicate-name ValueError to avoid ambiguous SELECT output.","triggerScenarios":"Two inputs both contributing a column named 'id' via list form, e.g. fields: {left: [id], right: [id]}.","commonSituations":"Joins between tables that share key column names (id, key, name); users forgetting that list form emits the raw column name, unlike dict form which allows renaming.","solutions":["Use the dict form to rename one occurrence: right: {right_id: id}.","Remove the duplicate column from one input's list.","Exclude the conflicting column and rely on the default table.* expansion carefully, renaming upstream."],"exampleFix":"// before\nfields:\n  left: [id]\n  right: [id]\n// after\nfields:\n  left: [id]\n  right: {right_id: id}","handlingStrategy":"validation","validationCode":"def check_unique_names(fields):\n    seen = set()\n    for alias, cols in fields.items():\n        names = cols if isinstance(cols, list) else (cols.keys() if isinstance(cols, dict) else [])\n        for n in names:\n            if n in seen:\n                raise ValueError(f'duplicate output field: {n}')\n            seen.add(n)","typeGuard":null,"tryCatchPattern":"try:\n    result = SqlJoinTransform(config)\nexcept ValueError as e:\n    if 'specified more than once' in str(e):\n        raise ConfigError('rename one of the duplicate output fields with dict form') from e\n    raise","preventionTips":["Use dict form {outName: col} to rename shared columns like id","List output names across inputs before finalizing the spec","Prefer explicit renaming for join-key columns with common names"],"tags":["apache-beam","yaml","validation","duplicate"],"backgroundTag":"conflicting-config-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"}