Skip to content

refactor: Add read_from() and write_to() to TableMetadata #1523

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

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

Conversation

CTTY
Copy link
Contributor

@CTTY CTTY commented Jul 18, 2025

Which issue does this PR close?

What changes are included in this PR?

  • Add TableMetadataIO to read/write metadata from/to a location

Are these changes tested?

Added unit test

@CTTY CTTY changed the title refactor: Add TableMetadataIO to read and write metadata refactor: Add read() and write() to TableMetadata Jul 18, 2025
.new_output(&metadata_location)?
.write(serde_json::to_vec(&metadata)?.into())
.await?;
TableMetadata::write(&self.file_io, &metadata, &metadata_location).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also found MetadataLocation proposed here quite interesting:

Would love to hear more thoughts about it

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should not change the interface here. We could change the write interface to sth like following:

fn write(&self, impl ToString)

to generalize the arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to

fn write(&self, impl AsRef<str>)

because file_io.new_input/new_output takes AsRef<str>

liurenjie1024
liurenjie1024 previously approved these changes Jul 22, 2025
Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

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

Thanks @CTTY for this pr, generally LGTM! Just one minor nit!

.new_output(&metadata_location)?
.write(serde_json::to_vec(&metadata)?.into())
.await?;
TableMetadata::write(&self.file_io, &metadata, &metadata_location).await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should not change the interface here. We could change the write interface to sth like following:

fn write(&self, impl ToString)

to generalize the arguments.

@CTTY CTTY changed the title refactor: Add read() and write() to TableMetadata refactor: Add read_from() and write_to() to TableMetadata Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement saving TableMetadata to new location.
2 participants