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

fix: add raise_if_key_not_exists to CreateBuilder #2565

Merged
merged 2 commits into from
Jun 4, 2024
Merged

fix: add raise_if_key_not_exists to CreateBuilder #2565

merged 2 commits into from
Jun 4, 2024

Conversation

vegarsti
Copy link
Contributor

@vegarsti vegarsti commented Jun 3, 2024

This PR adds a raise_if_key_not_exists flag to the CreateBuilder which we propagate (currently always true), such that users can choose not to fail if the configuration contains a key that is not a valid DeltaConfigKey. Also expose this in the Python binding.

Closes #2564.

@ion-elgreco

@github-actions github-actions bot added the binding/rust Issues for the Rust crate label Jun 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

ACTION NEEDED

delta-rs follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

@vegarsti vegarsti changed the title Add raise_if_key_not_exists to CreateBuilder fix: add raise_if_key_not_exists to CreateBuilder Jun 3, 2024
@ion-elgreco
Copy link
Collaborator

Can you expose this to python as well

@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 3, 2024

Yeah! The approach is ok?

@ion-elgreco
Copy link
Collaborator

Yeah! The approach is ok?

Yess, if you can also add one test to check if non delta keys are getting passed through and so forth.

@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

Would you mind pointing me to the relevant Python file? 😄 Is it deltalake/table.py?

@ion-elgreco
Copy link
Collaborator

Would you mind pointing me to the relevant Python file? 😄 Is it deltalake/table.py?

Yes there! And python/src/lib.rs

@github-actions github-actions bot added the binding/python Issues for the Python package label Jun 4, 2024
@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

Thanks! Added now, let me know if it doesn't make sense. Will add the test you mentioned as well.

@@ -457,6 +457,7 @@ def create(
configuration: Optional[Mapping[str, Optional[str]]] = None,
storage_options: Optional[Dict[str, str]] = None,
custom_metadata: Optional[Dict[str, str]] = None,
raise_if_key_not_exists: Optional[bool] = True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would keep it required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fair! Should I move it further up in the signature, then, i.e. before the Optional ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or wait, I'll still use the default True, so it should be fine

Copy link
Collaborator

Choose a reason for hiding this comment

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

Best to keep it aligned across :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by that 🤔 Had to move it further up in create_deltalake: The Rust code was failing to compile because of the ambigious ordering (it wants non-optional before optional ones).

@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

BTW the order in the create classmethod and and create_deltalake aren't exactly the same (before the change in this PR)

@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

Added test to the Rust code now

@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

Should I squash the Rust and Python commits?

@ion-elgreco
Copy link
Collaborator

Should I squash the Rust and Python commits?

No worries, I'll do that with the merge commit

Copy link
Collaborator

@ion-elgreco ion-elgreco left a comment

Choose a reason for hiding this comment

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

Thankss @vegarsti!

@ion-elgreco ion-elgreco merged commit d65b4d6 into delta-io:main Jun 4, 2024
24 of 25 checks passed
@vegarsti
Copy link
Contributor Author

vegarsti commented Jun 4, 2024

Thanks for helping so quickly!

@@ -196,6 +198,12 @@ impl CreateBuilder {
self
}

/// Specify whether to raise an error if the table properties in the configuration are not DeltaConfigKeys
pub fn with_raise_if_not_exists(mut self, raise_if_key_not_exists: bool) -> Self {
Copy link
Contributor Author

@vegarsti vegarsti Jun 4, 2024

Choose a reason for hiding this comment

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

oops @ion-elgreco I messed this up -- should have been with_raise_if_key_not_exists for consistency

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vegarsti oops :), you can make a small follow up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ion-elgreco pushed a commit that referenced this pull request Jun 4, 2024
I forgot to change the name of the builder method!

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

Successfully merging this pull request may close these issues.

raise_if_not_exists for properties not configurable on CreateBuilder
2 participants