From 3fad074bcc502902de86b5818374c9b899e01380 Mon Sep 17 00:00:00 2001 From: Ion Koutsouris <15728914+ion-elgreco@users.noreply.github.com> Date: Sun, 24 Nov 2024 16:09:01 +0100 Subject: [PATCH] fix(python): Parse uppercase config keys (#19852) --- crates/polars-io/src/cloud/options.rs | 52 ++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/crates/polars-io/src/cloud/options.rs b/crates/polars-io/src/cloud/options.rs index ea5376b6865f..545ab5550890 100644 --- a/crates/polars-io/src/cloud/options.rs +++ b/crates/polars-io/src/cloud/options.rs @@ -120,16 +120,15 @@ fn parsed_untyped_config, impl Into>>() + .collect::>()) } #[derive(PartialEq)] @@ -607,7 +606,9 @@ impl CloudOptions { #[cfg(feature = "cloud")] #[cfg(test)] mod tests { - use super::parse_url; + use hashbrown::HashMap; + + use super::{parse_url, parsed_untyped_config}; #[test] fn test_parse_url() { @@ -682,4 +683,39 @@ mod tests { ); } } + #[cfg(feature = "aws")] + #[test] + fn test_parse_untyped_config() { + use object_store::aws::AmazonS3ConfigKey; + + let aws_config = [ + ("aws_secret_access_key", "a_key"), + ("aws_s3_allow_unsafe_rename", "true"), + ] + .into_iter() + .collect::>(); + let aws_keys = parsed_untyped_config::(aws_config) + .expect("Parsing keys shouldn't have thrown an error"); + + assert_eq!( + aws_keys.first().unwrap().0, + AmazonS3ConfigKey::SecretAccessKey + ); + assert_eq!(aws_keys.len(), 1); + + let aws_config = [ + ("AWS_SECRET_ACCESS_KEY", "a_key"), + ("aws_s3_allow_unsafe_rename", "true"), + ] + .into_iter() + .collect::>(); + let aws_keys = parsed_untyped_config::(aws_config) + .expect("Parsing keys shouldn't have thrown an error"); + + assert_eq!( + aws_keys.first().unwrap().0, + AmazonS3ConfigKey::SecretAccessKey + ); + assert_eq!(aws_keys.len(), 1); + } }