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: make PartitionSpec more safe #550

Open
liurenjie1024 opened this issue Aug 14, 2024 · 2 comments · May be fixed by #645
Open

refactor: make PartitionSpec more safe #550

liurenjie1024 opened this issue Aug 14, 2024 · 2 comments · May be fixed by #645

Comments

@liurenjie1024
Copy link
Collaborator

This discussion is a follow up of this comment, in summary, I'm thinking about make PartitionSpec safe with following changes:

  1. Making all fields private to this struct.
  2. Add a schema field to PartitionSpec.

This will introduce several changes:

  1. PartitionSpec could only be built using builder, which has checks for serveral parts to ensure it's correct
  2. PartitionSpec's partition type could be infered by itself
  3. We may need to change the deserialization of TableMetadata to use builder to build it.
@liurenjie1024
Copy link
Collaborator Author

cc @c-thiel @Xuanwo

@c-thiel
Copy link
Contributor

c-thiel commented Sep 9, 2024

@liurenjie1024 we just need to be very careful with old PartitionSpecs: They might not be valid anymore for the current schema - yet, we still want to keep them.
In these cases Java has schema field pointing to the current schema, even if fields might not be present. Java achieves this by using build_unchecked.

In think it would be much cleaner to use UnboundPartitionSpecs for these cases.
We could change TableMetadata to

pub struct TableMetadata {
...
    pub(crate) partition_specs: HashMap<i32, UnboundPartitionSpecRef>,  // Changed to unbound
    pub(crate) default_spec: PartitionSpecRef, // This is a new field bound to the current schema.
    // Remove: default_spec_id - get it from default_spec.id
}

@c-thiel c-thiel linked a pull request Sep 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants