Jefffrey commented on code in PR #18187:
URL: https://github.com/apache/datafusion/pull/18187#discussion_r2450343285


##########
datafusion/common/src/table_reference.rs:
##########
@@ -269,24 +269,64 @@ impl TableReference {
     }
 
     /// Forms a [`TableReference`] by parsing `s` as a multipart SQL
-    /// identifier. See docs on [`TableReference`] for more details.
+    /// identifier, normalizing `s` to lowercase.
+    /// See docs on [`TableReference`] for more details.
     pub fn parse_str(s: &str) -> Self {
-        let mut parts = parse_identifiers_normalized(s, false);
+        Self::parse_str_normalized(s, false)
+    }
+
+    /// Forms a [`TableReference`] by parsing `s` as a multipart SQL
+    /// identifier, normalizing `s` to lowercase if `ignore_case` is `false`.
+    /// See docs on [`TableReference`] for more details.
+    pub fn parse_str_normalized(s: &str, ignore_case: bool) -> Self {
+        let table_parts = parse_identifiers_normalized(s, ignore_case);
+
+        Self::from_vec(table_parts).unwrap_or_else(|| Self::Bare { table: 
s.into() })
+    }
 
+    /// Copy from a slice of identifier parts to compose a [`TableReference`]. 
The input slice
+    /// should contain 1 <= N <= 3 elements in the following sequence:
+    /// ```no_rust
+    /// [<catalog>, <schema>, table]
+    /// ```
+    pub fn from_slice(parts: &[impl AsRef<str>]) -> Option<Self> {

Review Comment:
   Is this meant to be used somewhere?



##########
datafusion/common/src/table_reference.rs:
##########
@@ -269,24 +269,64 @@ impl TableReference {
     }
 
     /// Forms a [`TableReference`] by parsing `s` as a multipart SQL
-    /// identifier. See docs on [`TableReference`] for more details.
+    /// identifier, normalizing `s` to lowercase.
+    /// See docs on [`TableReference`] for more details.
     pub fn parse_str(s: &str) -> Self {
-        let mut parts = parse_identifiers_normalized(s, false);
+        Self::parse_str_normalized(s, false)
+    }
+
+    /// Forms a [`TableReference`] by parsing `s` as a multipart SQL
+    /// identifier, normalizing `s` to lowercase if `ignore_case` is `false`.
+    /// See docs on [`TableReference`] for more details.
+    pub fn parse_str_normalized(s: &str, ignore_case: bool) -> Self {
+        let table_parts = parse_identifiers_normalized(s, ignore_case);
+
+        Self::from_vec(table_parts).unwrap_or_else(|| Self::Bare { table: 
s.into() })
+    }
 
+    /// Copy from a slice of identifier parts to compose a [`TableReference`]. 
The input slice
+    /// should contain 1 <= N <= 3 elements in the following sequence:
+    /// ```no_rust
+    /// [<catalog>, <schema>, table]
+    /// ```
+    pub fn from_slice(parts: &[impl AsRef<str>]) -> Option<Self> {
         match parts.len() {
-            1 => Self::Bare {
-                table: parts.remove(0).into(),
-            },
-            2 => Self::Partial {
-                schema: parts.remove(0).into(),
-                table: parts.remove(0).into(),
-            },
-            3 => Self::Full {
-                catalog: parts.remove(0).into(),
-                schema: parts.remove(0).into(),
-                table: parts.remove(0).into(),
-            },
-            _ => Self::Bare { table: s.into() },
+            1 => Some(Self::Bare {
+                table: parts[0].as_ref().into(),
+            }),
+            2 => Some(Self::Partial {
+                schema: parts[0].as_ref().into(),
+                table: parts[1].as_ref().into(),
+            }),
+            3 => Some(Self::Full {
+                catalog: parts[0].as_ref().into(),
+                schema: parts[1].as_ref().into(),
+                table: parts[2].as_ref().into(),
+            }),
+            _ => None,
+        }
+    }
+
+    /// Consume a vector of identifier parts to compose a [`TableReference`]. 
The input vector
+    /// should contain 1 <= N <= 3 elements in the following sequence:
+    /// ```no_rust
+    /// [<catalog>, <schema>, table]
+    /// ```
+    pub fn from_vec(mut parts: Vec<String>) -> Option<Self> {

Review Comment:
   Maybe we should keep it private until we have a need to expose it? Or would 
it be generally useful enough to users to make it public now?



-- 
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