Skip to content

Commit

Permalink
handle params better
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Aug 14, 2023
1 parent 9bc0396 commit 4154dc3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
10 changes: 4 additions & 6 deletions rust/src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,10 @@ impl Dataset {
};

// Need to include params here because it might include a commit mechanism.
let (object_store, _) = ObjectStore::from_uri_and_params(
&self.object_store.base_uri(),
params.store_params.clone().unwrap_or_default(),
)
.await?;
let object_store = Arc::new(object_store);
let object_store = Arc::new(
self.object_store()
.with_params(&params.store_params.clone().unwrap_or_default()),
);

let (stream, schema) = reader_to_stream(batches)?;

Expand Down
2 changes: 2 additions & 0 deletions rust/src/io/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ mod tests {
}
_ => unreachable!(),
}

dataset.validate().await.unwrap()
}
}
}
19 changes: 15 additions & 4 deletions rust/src/io/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,21 @@ impl ObjectStore {
))
}

pub fn with_params(&self, params: &ObjectStoreParams) -> Self {
Self {
inner: params
.object_store_wrapper
.as_ref()
.map(|w| w.wrap(self.inner.clone()))
.unwrap_or_else(|| self.inner.clone()),
commit_handler: params
.commit_handler
.clone()
.unwrap_or(self.commit_handler.clone()),
..self.clone()
}
}

fn new_from_path(str_path: &str, params: &ObjectStoreParams) -> Result<(Self, Path)> {
let expanded = tilde(str_path).to_string();
let expanded_path = StdPath::new(&expanded);
Expand Down Expand Up @@ -371,10 +386,6 @@ impl ObjectStore {
&self.base_path
}

pub fn base_uri(&self) -> String {
format!("{}://{}", self.scheme, self.base_path)
}

/// Open a file for path.
///
/// Parameters
Expand Down

0 comments on commit 4154dc3

Please sign in to comment.