Skip to content

Commit a33a3db

Browse files
authored
fix: retain metadata_location from StaticTable::into_table (#1536)
## Which issue does this PR close? - Closes #1535 ## What changes are included in this PR? `StaticTable::from_metadata_location` now retains the metadata location on the underlying `Table`. ## Are these changes tested? Yes, I added an assert.
1 parent a675031 commit a33a3db

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

crates/iceberg/src/table.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,23 @@ impl StaticTable {
271271
}
272272
/// Creates a static table directly from metadata file and `FileIO`
273273
pub async fn from_metadata_file(
274-
metadata_file_path: &str,
274+
metadata_location: &str,
275275
table_ident: TableIdent,
276276
file_io: FileIO,
277277
) -> Result<Self> {
278-
let metadata_file = file_io.new_input(metadata_file_path)?;
278+
let metadata_file = file_io.new_input(metadata_location)?;
279279
let metadata_file_content = metadata_file.read().await?;
280-
let table_metadata = serde_json::from_slice::<TableMetadata>(&metadata_file_content)?;
281-
Self::from_metadata(table_metadata, table_ident, file_io).await
280+
let metadata = serde_json::from_slice::<TableMetadata>(&metadata_file_content)?;
281+
282+
let table = Table::builder()
283+
.metadata(metadata)
284+
.metadata_location(metadata_location)
285+
.identifier(table_ident)
286+
.file_io(file_io.clone())
287+
.readonly(true)
288+
.build();
289+
290+
Ok(Self(table?))
282291
}
283292

284293
/// Create a TableScanBuilder for the static table.
@@ -356,6 +365,10 @@ mod tests {
356365
let table = static_table.into_table();
357366
assert!(table.readonly());
358367
assert_eq!(table.identifier.name(), "static_table");
368+
assert_eq!(
369+
table.metadata_location(),
370+
Some(metadata_file_path).as_deref()
371+
);
359372
}
360373

361374
#[tokio::test]

0 commit comments

Comments
 (0)