Skip to content

feat: Allow semantic comparison of schemas #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 17, 2025
Merged

feat: Allow semantic comparison of schemas #55

merged 10 commits into from
Jun 17, 2025

Conversation

borchero
Copy link
Member

@borchero borchero commented Jun 14, 2025

Motivation

Two schemas that define the same columns, with the same constraints, and the same set of the schema-level rules are generally considered equal.

Recently, I talked to @AndreasAlbertQC and @MoritzPotthoffQC about adding serialization of schemas to dataframely. This PR is a preparation to allow a schema X to be considered equal to a schema Y that is dynamically created from the serialization of X.

Changes

  • Add a matches method to the Schema class. One could also implement __eq__ in the metaclass to allow for Schema == Schema to be a semantic comparison. This has a bunch of weird effects though, so I refrained from doing that.
  • Implement a matches function for Column and Rule. Initially, I implemented __eq__ for them, but it feels more consistent to also implement a method named matches. It also allows to pass an additional parameter for evaluating Column equality (i.e. the name of the column) which will come in handy when performing serialization.

@borchero borchero self-assigned this Jun 14, 2025
@github-actions github-actions bot added the enhancement New feature or request label Jun 14, 2025
Copy link

codecov bot commented Jun 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8d4b41b) to head (673f3f0).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #55   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           39        39           
  Lines         1896      1947   +51     
=========================================
+ Hits          1896      1947   +51     

☔ 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.

@AndreasAlbertQC AndreasAlbertQC merged commit 18481c1 into main Jun 17, 2025
20 checks passed
@AndreasAlbertQC AndreasAlbertQC deleted the equality branch June 17, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants