-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat: Reassign field ids for schema #615
base: main
Are you sure you want to change the base?
Conversation
/// If not provided, it will start from 0. | ||
/// | ||
/// All specified aliases and identifier fields will be updated to the new field-ids. | ||
pub fn with_reassigned_field_ids(mut self, start_from: Option<i32>) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on the circumstances under which the user wants to set this? I used to think users always need to start with 0
.
/// | ||
/// All specified aliases and identifier fields will be updated to the new field-ids. | ||
pub fn with_reassigned_field_ids(mut self, start_from: Option<i32>) -> Self { | ||
self.reassign_field_ids_from = Some(start_from.unwrap_or(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we always set Some(v)
here, how about just using i32
for reassign_field_ids_from
with default value 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically you would pass in last-column-id
from the table metadata. In the case of a CREATE TABLE
this will be zero, in the case of a REPLACE TABLE
it will be last-column-id
where all columns get a new ID and you ensure they are not used before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Xuanwo only doubt with the i32 is that people might input 1 as something is required - and it's shorter than Default::default().
The rust tests are quite a good example that this can happen: We have many tests where field numbering starts from 1, so I had to re-write them to be compatible with the new builder.
I am OK with the i32 as well, just wanted to bring up that a None is probably more verbose.
cc @liurenjie1024 would you like to take a look too? |
Required for
TableMetadataBuilder
(#587).When new TableMetadata is created, field ids should be reassign to ensure that field numbering is normalized and started from 0.