Skip to content

fix: Raise on duplicated aliases#291

Merged
AndreasAlbertQC merged 3 commits intoQuantco:mainfrom
gab23r:raise-duplicated-alias
Mar 4, 2026
Merged

fix: Raise on duplicated aliases#291
AndreasAlbertQC merged 3 commits intoQuantco:mainfrom
gab23r:raise-duplicated-alias

Conversation

@gab23r
Copy link
Contributor

@gab23r gab23r commented Mar 3, 2026

Raises an ImplementationError when a schema contains columns with duplicate aliases.

Motivation

I was using LLM to generate dataframely schemas, it gives me duplicated alias like in:

class MySchema(dy.Schema):
    a = dy.Int64(alias="a")
    b = dy.Int64(alias="a")

It could be nice from dataframely it icould raise in this case.

Changes

  • Detect duplicate aliases within a single schema
  • Detect duplicate aliases when inheriting from a parent schema
  • Add tests for both cases

Copilot AI review requested due to automatic review settings March 3, 2026 15:46
@gab23r gab23r changed the title Raise on duplicated aliases feat: Raise on duplicated aliases Mar 3, 2026
@github-actions github-actions bot added the enhancement New feature or request label Mar 3, 2026
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b3edd6a) to head (08efe2b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #291   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           54        54           
  Lines         3121      3127    +6     
=========================================
+ Hits          3121      3127    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds early validation to schema definition to prevent ambiguous schemas where multiple Columns resolve to the same effective column name (via alias), raising ImplementationError during class creation and adding regression tests.

Changes:

  • Raise ImplementationError when two columns in the same schema resolve to the same name (alias or attribute name).
  • Raise ImplementationError when a child schema introduces a column whose resolved name clashes with an inherited one.
  • Add tests covering both same-schema and inherited duplicate-alias scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dataframely/_base_schema.py Adds duplicate-name checks during metadata collection/merging to raise ImplementationError early.
tests/columns/test_alias.py Adds tests asserting duplicate aliases are rejected for same-schema and inherited definitions.

@AndreasAlbertQC AndreasAlbertQC changed the title feat: Raise on duplicated aliases fix: Raise on duplicated aliases Mar 4, 2026
@github-actions github-actions bot added the fix label Mar 4, 2026
Copy link
Collaborator

@AndreasAlbertQC AndreasAlbertQC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gab23r !

@AndreasAlbertQC AndreasAlbertQC enabled auto-merge (squash) March 4, 2026 18:51
@AndreasAlbertQC AndreasAlbertQC merged commit 4adee6f into Quantco:main Mar 4, 2026
34 checks passed
@gab23r gab23r deleted the raise-duplicated-alias branch March 4, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants