Skip to content
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

fix: reinstate copy-if-not-exists passthrough #2083

Merged
merged 5 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/deltalake-aws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod logstore;
pub mod storage;

use lazy_static::lazy_static;
use object_store::aws::AmazonS3ConfigKey;
use regex::Regex;
use std::{
collections::HashMap,
Expand Down Expand Up @@ -41,6 +42,17 @@ impl LogStoreFactory for S3LogStoreFactory {
options: &StorageOptions,
) -> DeltaResult<Arc<dyn LogStore>> {
let store = url_prefix_handler(store, Path::parse(location.path())?)?;

if options
.0
.contains_key(AmazonS3ConfigKey::CopyIfNotExists.as_ref())
{
debug!("S3LogStoreFactory has been asked to create a LogStore where the underlying store has copy-if-not-exists enabled - no locking provider required");
return Ok(deltalake_core::logstore::default_logstore(
store, location, options,
));
}

let s3_options = S3StorageOptions::from_map(&options.0);

if s3_options.locking_provider.as_deref() != Some("dynamodb") {
Expand Down
9 changes: 9 additions & 0 deletions crates/deltalake-aws/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ impl ObjectStoreFactory for S3ObjectStoreFactory {
}),
)?;

if options
.0
.contains_key(AmazonS3ConfigKey::CopyIfNotExists.as_ref())
{
// If the copy-if-not-exists env var is set, we don't need to instantiate a locking client or check for allow-unsafe-rename.
return Ok((Arc::from(store), prefix));
}

let options = S3StorageOptions::from_map(&options.0);

let store = S3StorageBackend::try_new(
store.into(),
Some("dynamodb") == options.locking_provider.as_deref() || options.allow_unsafe_rename,
Expand Down
Loading