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

refactor: replaced asterisk with constraint name in get_constraints #3270

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Nordalf
Copy link
Contributor

@Nordalf Nordalf commented Feb 26, 2025

Description

When retrieving constraints from the table config, the name is set to an asterisk (*). The name is needed if you want to e.g. drop the constraint again. I have modified the code to use the found keys excluding delta.constraints..

Before:

"name": "*",
"expr": "double LIKE 'DO%' AND double LIKE '%IT%'"

After:

"name": "my_new_constraint_name",
"expr": "double LIKE 'DO%' AND double LIKE '%IT%'"

Going through the code, I discovered the reason behind using the asterisk. It was for the delta_datafusion::enforce_checks function to format its SQL-query with SELECT * ... in a constraint check. To ensure the enforce_checks function still works, I have expanded the DeltaCheck trait to include as_any() to allow type checking in enforce_checks to condition how the SQL-query must be formatted for different checks.

Related Issue(s)

No related issues

Documentation

No documentation

…or table config

Signed-off-by: Alexander Falk <alexfalk7@gmail.com>
@github-actions github-actions bot added the binding/rust Issues for the Rust crate label Feb 26, 2025
@ion-elgreco
Copy link
Collaborator

@Nordalf can you add a test please :)

@Nordalf
Copy link
Contributor Author

Nordalf commented Feb 26, 2025

@ion-elgreco , of course. I will add a test a little later 🚀

Edit: Already seeing the first problem in enforce_checks. Taking a closer look

…checks

Signed-off-by: Alexander Falk <alexfalk7@gmail.com>
… name or asterisk

Signed-off-by: Alexander Falk <alexfalk7@gmail.com>
Signed-off-by: Alexander Falk <alexfalk7@gmail.com>
…traints

Signed-off-by: Alexander Falk <alexfalk7@gmail.com>
@Nordalf
Copy link
Contributor Author

Nordalf commented Feb 27, 2025

@ion-elgreco check out the updated code. I have modified the DeltaCheck trait with as_any(). Explanation can be seen in my updated description.

I have also included two new tests: one for get_constraints and one for enforce_checks on constraints.

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 10 lines in your changes missing coverage. Please review.

Project coverage is 72.13%. Comparing base (94a2009) to head (c75e0df).

Files with missing lines Patch % Lines
crates/core/src/delta_datafusion/mod.rs 89.09% 0 Missing and 6 partials ⚠️
crates/core/src/table/mod.rs 50.00% 3 Missing ⚠️
crates/core/src/operations/constraints.rs 95.83% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3270      +/-   ##
==========================================
+ Coverage   72.11%   72.13%   +0.02%     
==========================================
  Files         143      143              
  Lines       45530    45617      +87     
  Branches    45530    45617      +87     
==========================================
+ Hits        32833    32907      +74     
- Misses      10618    10625       +7     
- Partials     2079     2085       +6     

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

@ion-elgreco
Copy link
Collaborator

@Nordalf looks good, can you squash the commits? Then we can merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/rust Issues for the Rust crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants