{"record":{"id":"de3c28bf4e770858","repo":"pola-rs/polars","slug":"duplicate-column-name-column-info-name","errorCode":null,"errorMessage":"duplicate column name: {column_info.name}","messagePattern":"duplicate column name: (.+?)","errorType":"exception","errorClass":"DuplicateError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/catalog/unity/models.py","lineNumber":85,"sourceCode":"        \"\"\"\n        Get the native polars schema of this table.\n\n        .. warning::\n            This functionality is considered **unstable**. It may be changed\n            at any point without it being considered a breaking change.\n        \"\"\"\n        issue_unstable_warning(\n            \"`get_polars_schema` functionality is considered unstable.\"\n        )\n        if self.columns is None:\n            return None\n\n        schema = Schema()\n\n        for column_info in self.columns:\n            if column_info.name in schema:\n                msg = f\"duplicate column name: {column_info.name}\"\n                raise DuplicateError(msg)\n            schema[column_info.name] = column_info.get_polars_dtype()\n\n        return schema\n\n\n@dataclass\nclass ColumnInfo:\n    \"\"\"Information for a column within a catalog table.\"\"\"\n\n    name: str\n    type_name: str\n    type_text: str\n    type_json: str\n    position: int | None\n    comment: str | None\n    partition_index: int | None\n\n    def get_polars_dtype(self) -> DataType:","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/catalog/unity/models.py#L67-L103","documentation":"Validation in Table.get_polars_schema: while building the Schema from the Unity Catalog table's column metadata, a column name already present in the schema is encountered, so the table metadata holds duplicate column names and no unambiguous schema can be produced.","triggerScenarios":"Calling TableInfo.get_polars_schema() (used by scan_table/read paths) when self.columns has repeated names — e.g. corrupt catalog metadata or a case-insensitive duplicate the catalog accepted.","commonSituations":"Manually inserted/edited catalog metadata; catalogs that allow case-differing duplicate names ('A' vs 'a'); buggy table-creation tooling.","solutions":["Inspect the table's columns in the catalog and remove/rename the duplicate","Fix the table definition in Unity Catalog via ALTER TABLE / DROP COLUMN","If columns differ only by case, rename one column to make names unique","Update catalog metadata directly if it is corrupt"],"exampleFix":"// before\ncolumns = [ColumnInfo(name='id', ...), ColumnInfo(name='id', ...)]\ntable.get_polars_schema()  # DuplicateError\n// after\ncolumns = [ColumnInfo(name='id', ...), ColumnInfo(name='id_2', ...)]\ntable.get_polars_schema()  # ok","handlingStrategy":"try-catch","validationCode":"names = [c.name for c in table_info.columns]\ndups = {n for n in names if names.count(n) > 1}\nif dups:\n    raise ValueError(f'duplicate columns: {dups}')","typeGuard":null,"tryCatchPattern":"try:\n    schema = table_info.get_polars_schema()\nexcept DuplicateError as e:\n    logging.error('catalog metadata has duplicate columns: %s', e)\n    raise","preventionTips":["Enforce unique column names at table creation","Watch for case-insensitive duplicates ('A' vs 'a')","Validate catalog metadata after manual edits"],"tags":["unity-catalog","schema","duplicate-column"],"backgroundTag":"schema-validation-failed","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}