Skip to content
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

Bugfix: NoOverlap2d constraint fails to recognize duplicates #256

Merged
merged 11 commits into from
Jan 20, 2025
Merged

Conversation

kklein
Copy link
Collaborator

@kklein kklein commented Jan 12, 2025

Bug detected by @EgeKaraismailogluQC.

Failing example: 79aff3b

Fundamentally, the overlap detection contained a flaw in which the 'left' bound of two intervals could not be equal for them to be considered overlapping. A special case of this situation is when two intervals are exactly equal - the counterexample which made this bug apparent.

Importantly, this bug affects all overlap-related constraints.

The bug is fixed in datajudge.db_access.get_interval_overlaps_nd by:

  • Replacing a strict inequality by an equality
  • Explicitly handling the case where an n-dimensional interval is duplicated; if we didn't handle this explicitly we would always find an 'overlap' for a table is joined with itself

Test cases are added for all relevant overlap-constraint-adding methods.

Copy link

codecov bot commented Jan 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.38%. Comparing base (efb059f) to head (58dfa87).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #256      +/-   ##
==========================================
+ Coverage   93.36%   93.38%   +0.02%     
==========================================
  Files          18       18              
  Lines        1988     1996       +8     
==========================================
+ Hits         1856     1864       +8     
  Misses        132      132              

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

@kklein kklein added ready and removed postgres labels Jan 12, 2025
@kklein kklein marked this pull request as ready for review January 12, 2025 13:15
@kklein
Copy link
Collaborator Author

kklein commented Jan 12, 2025

@ivergara I believe it is necessary to manually tear down some integration test data, since the content of some tables has changed and we don't have an automatic teardown for snowflake. Would you be so kind to do this @ivergara ? I don't think I have access to (and if so I have forgotten how to) enter the snowflake administration interface.

@EgeKaraismailogluQC
Copy link

@kklein thanks for tagging me here! I am not familiar enough with the codebase to approve or request changes, but I do have one question: why do we need to handle an exact match separately? It seems to me that our definition of an overlap in naive_violation_condition should cover exact matches.

@kklein
Copy link
Collaborator Author

kklein commented Jan 13, 2025

Thanks for taking a look @EgeKaraismailogluQC .

why do we need to handle an exact match separately?

In order to determine whether there are overlaps within a table, we merge the table onto itself with the 'overlap condition' as a join condition. Hence naive_violation_condition will always find a violation: a row overlaps with itself.

Does that make sense?

@ivergara
Copy link
Collaborator

@ivergara I believe it is necessary to manually tear down some integration test data, since the content of some tables has changed and we don't have an automatic teardown for snowflake. Would you be so kind to do this @ivergara ? I don't think I have access to (and if so I have forgotten how to) enter the snowflake administration interface.

Will take a look. I do still know how to log in, and I hope that by deleting the data it'll be enough.

@EgeKaraismailogluQC
Copy link

@kklein makes sense, thanks!

@kklein
Copy link
Collaborator Author

kklein commented Jan 20, 2025

Thanks @ivergara - the tests are passing now :)
Do you think you could review the PR?

@ivergara ivergara merged commit 21eef1b into main Jan 20, 2025
57 checks passed
@ivergara ivergara deleted the eges_catch branch January 20, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants