Skip to content

Commit b1940e9

Browse files
committed
minor fixes
1 parent 7548830 commit b1940e9

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

cpp/src/arrow/filesystem/s3fs.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,14 @@ Result<T> GetOption(const std::string& key, const std::any& value) {
347347
return Status::Invalid("S3 filesystem option '", key, "' has the wrong type");
348348
}
349349

350+
template <typename T>
351+
Result<std::shared_ptr<const T>> GetConstSharedPtrOption(const std::string& key,
352+
const std::any& value) {
353+
if (const auto* v = std::any_cast<std::shared_ptr<const T>>(&value)) return *v;
354+
if (const auto* v = std::any_cast<std::shared_ptr<T>>(&value)) return *v;
355+
return Status::Invalid("S3 filesystem option '", key, "' has the wrong type");
356+
}
357+
350358
} // namespace
351359

352360
Result<S3Options> S3Options::FromUriAndOptions(const ::arrow::util::Uri& uri,
@@ -367,7 +375,7 @@ Result<S3Options> S3Options::FromUriAndOptions(const ::arrow::util::Uri& uri,
367375
GetOption<std::shared_ptr<S3RetryStrategy>>(key, value));
368376
} else if (key == "default_metadata") {
369377
ARROW_ASSIGN_OR_RAISE(default_metadata,
370-
GetOption<std::shared_ptr<KeyValueMetadata>>(key, value));
378+
GetConstSharedPtrOption<KeyValueMetadata>(key, value));
371379
} else {
372380
return Status::Invalid("Unexpected option for S3 filesystem: '", key, "'");
373381
}

cpp/src/arrow/filesystem/s3fs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ struct ARROW_EXPORT S3Options {
299299
/// - "secret_key" (std::string)
300300
/// - "session_token" (std::string)
301301
/// - "retry_strategy" (std::shared_ptr<S3RetryStrategy>)
302+
/// - "default_metadata" (std::shared_ptr<const KeyValueMetadata>)
302303
/// Options take precedence over the URI; unknown keys or invalid values return
303304
/// Status::Invalid.
304305
static Result<S3Options> FromUriAndOptions(const ::arrow::util::Uri& uri,

0 commit comments

Comments
 (0)