-
Notifications
You must be signed in to change notification settings - Fork 456
refactor: replace HashMap with TableProperties in TableMetadata (#2028) #2037
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
Changes from 1 commit
a0b53f8
c8e2003
4af9794
cfd42b7
ffbb917
849740a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,7 +110,7 @@ impl TableMetadataBuilder { | |
| ), // Overwritten immediately by add_default_partition_spec | ||
| default_partition_type: StructType::new(vec![]), | ||
| last_partition_id: UNPARTITIONED_LAST_ASSIGNED_ID, | ||
| properties: HashMap::new(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think in |
||
| properties: TableProperties::default(), | ||
| current_snapshot_id: None, | ||
| snapshots: HashMap::new(), | ||
| snapshot_log: vec![], | ||
|
|
@@ -272,7 +272,7 @@ impl TableMetadataBuilder { | |
| return Ok(self); | ||
| } | ||
|
|
||
| self.metadata.properties.extend(properties.clone()); | ||
| self.metadata.properties.other.extend(properties.clone()); | ||
| self.changes.push(TableUpdate::SetProperties { | ||
| updates: properties, | ||
| }); | ||
|
|
@@ -307,7 +307,7 @@ impl TableMetadataBuilder { | |
| } | ||
|
|
||
| for property in &properties { | ||
| self.metadata.properties.remove(property); | ||
| self.metadata.properties.other.remove(property); | ||
| } | ||
|
|
||
| if !properties.is_empty() { | ||
|
|
@@ -1128,6 +1128,7 @@ impl TableMetadataBuilder { | |
| let max_size = self | ||
| .metadata | ||
| .properties | ||
| .other | ||
| .get(TableProperties::PROPERTY_METADATA_PREVIOUS_VERSIONS_MAX) | ||
| .and_then(|v| v.parse::<usize>().ok()) | ||
| .unwrap_or(TableProperties::PROPERTY_METADATA_PREVIOUS_VERSIONS_MAX_DEFAULT) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,7 +35,7 @@ where | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /// TableProperties that contains the properties of a table. | ||||||||||||||||||||||||||||||||||||
| #[derive(Debug)] | ||||||||||||||||||||||||||||||||||||
| #[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)] | ||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have dedicated ser/de for |
||||||||||||||||||||||||||||||||||||
| pub struct TableProperties { | ||||||||||||||||||||||||||||||||||||
| /// The number of times to retry a commit. | ||||||||||||||||||||||||||||||||||||
| pub commit_num_retries: usize, | ||||||||||||||||||||||||||||||||||||
|
|
@@ -51,6 +51,8 @@ pub struct TableProperties { | |||||||||||||||||||||||||||||||||||
| pub write_target_file_size_bytes: usize, | ||||||||||||||||||||||||||||||||||||
| /// Whether to use `FanoutWriter` for partitioned tables. | ||||||||||||||||||||||||||||||||||||
| pub write_datafusion_fanout_enabled: bool, | ||||||||||||||||||||||||||||||||||||
| /// Any other properties that are not explicitly captured in named fields. | ||||||||||||||||||||||||||||||||||||
| pub other: HashMap<String, String>, | ||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field name is not very descriptive to what it actually holds |
||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl TableProperties { | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| pub other: HashMap<String, String>, | |
| } | |
| impl TableProperties { | |
| other: HashMap<String, String>, | |
| } | |
| impl TableProperties { | |
| /// Returns a reference to the map of additional, non-standard table properties. | |
| pub fn other(&self) -> &HashMap<String, String> { | |
| &self.other | |
| } | |
| /// Returns a mutable reference to the map of additional, non-standard table properties. | |
| pub fn other_mut(&mut self) -> &mut HashMap<String, String> { | |
| &mut self.other | |
| } |
Copilot
AI
Jan 16, 2026
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.
The new() method silently swallows errors via unwrap_or_default(), which could hide parsing failures for invalid property values. This differs from the original behavior where table_properties() returned a Result. Consider returning Result<Self, anyhow::Error> to preserve error handling capabilities, or at minimum document that invalid values fall back to defaults.
| pub fn new(props: HashMap<String, String>) -> Self { | |
| Self::try_from(&props).unwrap_or_default() | |
| pub fn new(props: HashMap<String, String>) -> Result<Self, anyhow::Error> { | |
| Self::try_from(&props) |
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.
We should not unwrap, just implement TryFrom.
Copilot
AI
Jan 16, 2026
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.
The other field is set to a full clone of the input props HashMap, but this includes all properties (even the ones that were already parsed into struct fields). This creates unnecessary duplication and memory overhead. Consider filtering out the explicitly parsed properties before storing in other.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -163,9 +163,9 @@ impl Transaction { | |||||
| return Ok(self.table); | ||||||
| } | ||||||
|
|
||||||
| let table_props = self.table.metadata().table_properties()?; | ||||||
| let table_props = self.table.metadata().table_properties(); | ||||||
|
|
||||||
| let backoff = Self::build_backoff(table_props)?; | ||||||
| let backoff = Self::build_backoff(table_props.clone())?; | ||||||
|
||||||
| let backoff = Self::build_backoff(table_props.clone())?; | |
| let backoff = Self::build_backoff(&table_props)?; |
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.
I think we should remove this method.