You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Weijun-H (via GitHub)" <gi...@apache.org> on 2023/04/03 20:43:33 UTC

[GitHub] [arrow-datafusion] Weijun-H commented on a diff in pull request #5778: feat: Quote column names if required in error messages

Weijun-H commented on code in PR #5778:
URL: https://github.com/apache/arrow-datafusion/pull/5778#discussion_r1156439490


##########
datafusion/common/src/utils.rs:
##########
@@ -166,8 +167,26 @@ where
 /// the identifier by replacing it with two double quotes
 ///
 /// e.g. identifier `tab.le"name` becomes `"tab.le""name"`
-pub fn quote_identifier(s: &str) -> String {
-    format!("\"{}\"", s.replace('"', "\"\""))
+pub fn quote_identifier(s: &str) -> Cow<str> {
+    if needs_quotes(s) {
+        Cow::Owned(format!("\"{}\"", s.replace('"', "\"\"")))
+    } else {
+        Cow::Borrowed(s)
+    }
+}

Review Comment:
   Nice refactoring!



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org