You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "neumark (via GitHub)" <gi...@apache.org> on 2023/01/25 17:26:19 UTC

[GitHub] [arrow-datafusion] neumark commented on a diff in pull request #5059: Fix CREATE SCHEMA schema name double quoting issue.

neumark commented on code in PR #5059:
URL: https://github.com/apache/arrow-datafusion/pull/5059#discussion_r1086938147


##########
datafusion/sql/src/statement.rs:
##########
@@ -40,14 +40,39 @@ use datafusion_expr::{
 };
 use sqlparser::ast;
 use sqlparser::ast::{
-    Assignment, Expr as SQLExpr, Expr, Ident, ObjectName, ObjectType, Query, SetExpr,
-    ShowCreateObject, ShowStatementFilter, Statement, TableFactor, TableWithJoins,
-    UnaryOperator, Value,
+    Assignment, Expr as SQLExpr, Expr, Ident, ObjectName, ObjectType, Query, SchemaName,
+    SetExpr, ShowCreateObject, ShowStatementFilter, Statement, TableFactor,
+    TableWithJoins, UnaryOperator, Value,
 };
 use sqlparser::parser::ParserError::ParserError;
 use std::collections::{BTreeMap, HashMap, HashSet};
 use std::sync::Arc;
 
+fn ident_to_string(ident: &Ident) -> String {
+    ident.value.to_owned()
+}
+
+fn object_name_to_string(object_name: &ObjectName) -> String {
+    object_name
+        .0
+        .iter()
+        .map(ident_to_string)
+        .collect::<Vec<String>>()
+        .join(".")
+}
+
+fn get_schema_name(schema_name: &SchemaName) -> String {
+    match schema_name {
+        SchemaName::Simple(schema_name) => object_name_to_string(schema_name),
+        SchemaName::UnnamedAuthorization(auth) => ident_to_string(auth),
+        SchemaName::NamedAuthorization(schema_name, auth) => format!(
+            "{}.{}",
+            object_name_to_string(schema_name),

Review Comment:
   Hey, thank you so much for the quick and positive response!
   Honestly, I have no idea if `Foo` should become `foo`, but I'm happy to update the code to call `utils::normalize_ident()` on `ident.value` if necessary!



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