peterxcli commented on code in PR #23935:
URL: https://github.com/apache/datafusion/pull/23935#discussion_r3666954944


##########
datafusion/execution/src/object_store.rs:
##########
@@ -263,14 +263,22 @@ impl ObjectStoreRegistry for DefaultObjectStoreRegistry {
     }
 }
 
-/// Get the key of a url for object store registration.
-/// The credential info will be removed
+/// Get the key of a URL for object store registration.
+///
+/// The username portion of userinfo is preserved for ABFS schemes, where it
+/// identifies a namespace. Passwords and userinfo for other schemes are 
removed.
 fn get_url_key(url: &Url) -> String {
-    format!(
-        "{}://{}",
-        url.scheme(),
-        &url[url::Position::BeforeHost..url::Position::AfterPort],
-    )
+    let key_authority = match url.scheme() {
+        // ABFS encodes the container namespace in URL userinfo.
+        "abfs" | "abfss" if !url.username().is_empty() => format!(
+            "{}@{}",
+            &url[url::Position::BeforeUsername..url::Position::AfterUsername],
+            &url[url::Position::BeforeHost..url::Position::AfterPort],
+        ),
+        _ => 
url[url::Position::BeforeHost..url::Position::AfterPort].to_string(),
+    };
+
+    format!("{}://{key_authority}", url.scheme())

Review Comment:
   ```suggestion
       let authority_start = match url.scheme() {
           "abfs" | "abfss" if !url.username().is_empty() => 
url::Position::BeforeUsername,
           _ => url::Position::BeforeHost,
       };
   
       format!(
           "{}://{}",
           url.scheme(),
           &url[authority_start..url::Position::AfterPort],
       )
   ```



##########
datafusion/execution/src/object_store.rs:
##########
@@ -263,14 +263,18 @@ impl ObjectStoreRegistry for DefaultObjectStoreRegistry {
     }
 }
 
-/// Get the key of a url for object store registration.
-/// The credential info will be removed
+/// Get the key of a URL for object store registration.
+///
+/// Userinfo is preserved for ABFS schemes, where it identifies a namespace,
+/// and removed for all other schemes.
 fn get_url_key(url: &Url) -> String {
-    format!(
-        "{}://{}",
-        url.scheme(),
-        &url[url::Position::BeforeHost..url::Position::AfterPort],
-    )
+    let key_authority = match url.scheme() {
+        // ABFS encodes the container namespace in URL userinfo.
+        "abfs" | "abfss" => 
&url[url::Position::BeforeUsername..url::Position::AfterPort],
+        _ => &url[url::Position::BeforeHost..url::Position::AfterPort],
+    };
+
+    format!("{}://{key_authority}", url.scheme())

Review Comment:
   nvm



##########
datafusion/execution/src/object_store.rs:
##########
@@ -263,14 +263,18 @@ impl ObjectStoreRegistry for DefaultObjectStoreRegistry {
     }
 }
 
-/// Get the key of a url for object store registration.
-/// The credential info will be removed
+/// Get the key of a URL for object store registration.
+///
+/// Userinfo is preserved for ABFS schemes, where it identifies a namespace,
+/// and removed for all other schemes.
 fn get_url_key(url: &Url) -> String {
-    format!(
-        "{}://{}",
-        url.scheme(),
-        &url[url::Position::BeforeHost..url::Position::AfterPort],
-    )
+    let key_authority = match url.scheme() {
+        // ABFS encodes the container namespace in URL userinfo.
+        "abfs" | "abfss" => 
&url[url::Position::BeforeUsername..url::Position::AfterPort],
+        _ => &url[url::Position::BeforeHost..url::Position::AfterPort],
+    };
+
+    format!("{}://{key_authority}", url.scheme())

Review Comment:
   this suggestion looks good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to