Skip to content

Commit 28df4ec

Browse files
authored
fix: Interpret s3tables warehouse as table_location not metadata loca… (#2115)
## Which issue does this PR close? AWS [Docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-tables.html) state: > When you create a table, Amazon S3 automatically generates a warehouse location for the table. This is a unique S3 location that stores objects associated with the table. The following example shows the format of a warehouse location: ``` s3://63a8e430-6e0b-46f5-k833abtwr6s8tmtsycedn8s4yc3xhuse1b--table-s3 ``` We were previously interpreting this as as a metadata location (i.e. the path to the metadata.json file), this changes the code use it as a table location. - Closes #2114 ## What changes are included in this PR? Change how we construct the MetadataLocation object. ## Are these changes tested? There never appears to have been a test, and I don't have an AWS account to verify this. Note the test was initially developed by Claude Code and refined by me.
1 parent 7c2d5d1 commit 28df4ec

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

crates/catalog/s3tables/src/catalog.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ impl Catalog for S3TablesCatalog {
448448
.await
449449
.map_err(from_aws_sdk_error)?;
450450

451-
// prepare metadata location. the warehouse location is generated by s3tables catalog,
451+
// prepare table location. the warehouse location is generated by s3tables catalog,
452452
// which looks like: s3://e6c9bf20-991a-46fb-kni5xs1q2yxi3xxdyxzjzigdeop1quse2b--table-s3
453-
let metadata_location = match &creation.location {
453+
let table_location = match &creation.location {
454454
Some(_) => {
455455
return Err(Error::new(
456456
ErrorKind::DataInvalid,
@@ -467,16 +467,17 @@ impl Catalog for S3TablesCatalog {
467467
.send()
468468
.await
469469
.map_err(from_aws_sdk_error)?;
470-
let warehouse_location = get_resp.warehouse_location().to_string();
471-
MetadataLocation::new_with_table_location(warehouse_location).to_string()
470+
get_resp.warehouse_location().to_string()
472471
}
473472
};
474473

475474
// write metadata to file
476-
creation.location = Some(metadata_location.clone());
475+
creation.location = Some(table_location.clone());
477476
let metadata = TableMetadataBuilder::from_table_creation(creation)?
478477
.build()?
479478
.metadata;
479+
let metadata_location =
480+
MetadataLocation::new_with_table_location(table_location).to_string();
480481
metadata.write_to(&self.file_io, &metadata_location).await?;
481482

482483
// update metadata location

0 commit comments

Comments
 (0)