pola-rs/polars · error · DuplicateError
duplicate column name
Error message
duplicate column name: {column_info.name} What it means
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.
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
Example fix
// before columns = [ColumnInfo(name='id', ...), ColumnInfo(name='id', ...)] table.get_polars_schema() # DuplicateError // after columns = [ColumnInfo(name='id', ...), ColumnInfo(name='id_2', ...)] table.get_polars_schema() # ok
Defensive patterns
Strategy: try-catch
Validate before calling
names = [c.name for c in table_info.columns]
dups = {n for n in names if names.count(n) > 1}
if dups:
raise ValueError(f'duplicate columns: {dups}') Try / catch
try:
schema = table_info.get_polars_schema()
except DuplicateError as e:
logging.error('catalog metadata has duplicate columns: %s', e)
raise Prevention
- Enforce unique column names at table creation
- Watch for case-insensitive duplicates ('A' vs 'a')
- Validate catalog metadata after manual edits
When it happens
Trigger: 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.
Common situations: Manually inserted/edited catalog metadata; catalogs that allow case-differing duplicate names ('A' vs 'a'); buggy table-creation tooling.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- cannot create a second
- cannot : no data_source_format found
- cannot : no storage_location found
- cannot parse input into Polars data type
- column appears more than once in the query/result cursor
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/de3c28bf4e770858.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/catalog/unity/models.py:85
"""
Get the native polars schema of this table.
.. warning::
This functionality is considered **unstable**. It may be changed
at any point without it being considered a breaking change.
"""
issue_unstable_warning(
"`get_polars_schema` functionality is considered unstable."
)
if self.columns is None:
return None
schema = Schema()
for column_info in self.columns:
if column_info.name in schema:
msg = f"duplicate column name: {column_info.name}"
raise DuplicateError(msg)
schema[column_info.name] = column_info.get_polars_dtype()
return schema
@dataclass
class ColumnInfo:
"""Information for a column within a catalog table."""
name: str
type_name: str
type_text: str
type_json: str
position: int | None
comment: str | None
partition_index: int | None
def get_polars_dtype(self) -> DataType:View on GitHub (pinned to fe841f959e)