Skip to content

Commit b87e4f6

Browse files
Avoid collisions
1 parent 4842ed4 commit b87e4f6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

datafusion_iceberg/src/table.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,16 @@ impl TableProvider for DataFusionTable {
263263

264264
// Create a fake object store URL. Different table paths should produce fake URLs
265265
// that differ in the host name, because DF's DefaultObjectStoreRegistry only takes
266-
// hostname into account
266+
// hostname into account for object store keys
267267
fn fake_object_store_url(table_location_url: &str) -> Option<ObjectStoreUrl> {
268268
let mut u = url::Url::parse(table_location_url).ok()?;
269269
u.set_host(Some(&format!(
270-
"{}{}",
271-
u.host_str().unwrap_or("-"),
270+
"{}-0{}",
271+
u.host_str().unwrap_or("").replace('-', "-1"),
272272
u.path()
273-
.replace(object_store::path::DELIMITER, "-")
274-
.replace(':', "-")
273+
.replace('-', "-1")
274+
.replace(object_store::path::DELIMITER, "-2")
275+
.replace(':', "-3")
275276
)))
276277
.unwrap();
277278
u.set_path("");
@@ -1673,7 +1674,11 @@ mod tests {
16731674
fn test_fake_object_store_url() {
16741675
assert_eq!(
16751676
fake_object_store_url("s3://aaa/bbb/ccc"),
1676-
Some(ObjectStoreUrl::parse("s3://aaa-bbb-ccc").unwrap()),
1677+
Some(ObjectStoreUrl::parse("s3://aaa-0-2bbb-2ccc").unwrap()),
1678+
);
1679+
assert_eq!(
1680+
fake_object_store_url("s3://aaa/bbb-ccc"),
1681+
Some(ObjectStoreUrl::parse("s3://aaa-0-2bbb-1ccc").unwrap()),
16771682
);
16781683
assert_eq!(fake_object_store_url("invalid url"), None);
16791684
}

0 commit comments

Comments
 (0)