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

Derive Clone for the builders in object-store. #3419

Closed
winding-lines opened this issue Dec 31, 2022 · 6 comments · Fixed by #3424 or #3436
Closed

Derive Clone for the builders in object-store. #3419

winding-lines opened this issue Dec 31, 2022 · 6 comments · Fixed by #3424 or #3436
Labels
enhancement Any new improvement worthy of a entry in the changelog object-store Object Store Interface

Comments

@winding-lines
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

I am using the object-store create in polars. The async code is generally contained in a small number of functions. I plan to pass around builders (eg AmazonS3Builder, MicrosoftAzureBuilder, GoogleCloudStorageBuilder) and instantiate an object-store based on the urls that are being passed in. I cannot currently use one builder more than one since they don't implement Clone.

Is there a reason why these structs are not implementing Clone?

Describe the solution you'd like

Implement (most likely derive) Clone for AmazonS3Builder, MicrosoftAzureBuilder, GoogleCloudStorageBuilder and other object_store builders.

Describe alternatives you've considered

I can recreate the struct from their fields but then I will need to maintain the code on my side.

Additional context

@winding-lines winding-lines added the enhancement Any new improvement worthy of a entry in the changelog label Dec 31, 2022
@alamb
Copy link
Contributor

alamb commented Dec 31, 2022

I do not think there is any reason these structs can't implement clone. We would welcome a contribution to do so.

@winding-lines
Copy link
Contributor Author

@alamb unfortunately the Builders contain Result and Error fields which are not clonable and there is no easy way to make them clonable.

One option that I see is do a slight refactoring of the code where the data from the user is saved in a separate Config object, before any fallible processing is done. Then we can clone that part.

Note that delta-rs is also going through some hoops here: https://github.com/delta-io/delta-rs/tree/main/rust/src/builder

Let me know what you think.

@tustvold
Copy link
Contributor

unfortunately the Builders contain Result and Error fields which are not clonable and there is no easy way to make them clonable.

This is a relatively recent change, added in #3327, and not yet released. We could tweak the implementation of this slightly to make this simpler. I'll have a play

@winding-lines
Copy link
Contributor Author

Thanks @tustvold!

tustvold added a commit to tustvold/arrow-rs that referenced this issue Dec 31, 2022
@winding-lines
Copy link
Contributor Author

@alamb and @tustvold Happy New Year 2023!

I tested @tustvold 's branch inside my polars PR and what would help me tremendously is an extension of this issue. In addition to Clone it would be super helpful to also derive serde::Serializer and serde::Deserializer. I tested this on @tustvold 's branch and it just works on top of the existing cleanup. This affects the 3 builders an 2 transitively used struct.

Would it be ok to increase the scope? Many thanks!

@alamb
Copy link
Contributor

alamb commented Jan 1, 2023

I think adding Serialize and Deserialize would be just fine, though perhaps we could do it as a follow on PR?

I think it would simply require adding

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

To each of the builders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog object-store Object Store Interface
Projects
None yet
3 participants