goldmedal commented on code in PR #11724:
URL: https://github.com/apache/datafusion/pull/11724#discussion_r1701979383


##########
datafusion/common/src/column.rs:
##########
@@ -372,7 +372,7 @@ impl FromStr for Column {
 
 impl fmt::Display for Column {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", self.flat_name())
+        write!(f, "{}", self.quoted_flat_name())

Review Comment:
   > identifier could includes dot, that is the reason we need double quote to 
differentiate it from qualified column. Identifier with dot is relatively rare 
compare to column, so we don't have double quote every where.
   > 
   
   Agreed. That makes sense to me. A `Column` comprises multiple identifiers: 
`catalog.schema.table.column`. All the parts are `identifiers`. However, 
because we don't have an `Expr` for an `Identifier`, I can only handle it for 
`Column`. Currently, we represent an identifier as an unqualified column.
   
https://github.com/apache/datafusion/blob/0332eb569a5428ac385fe892ce7b5fb40d52c8c0/datafusion/expr/src/expr_fn.rs#L90-L92
   
   Ideally, all of the `names` should be identifiers (e.g., table name, column 
name, function name, or alias) that should be quoted if needed. This purpose 
will impact many parts.
   
   > I think only adding double quote for identifier that includes dot is 
probably a better idea.
   > 
   > If we have column that has name includes dot, we display it like 
`qualifier."dot.column"`
   
   I believe `quoted_flat_name()` that will invoke `quote_identifier` handles 
this logic well.
   
https://github.com/apache/datafusion/blob/0332eb569a5428ac385fe892ce7b5fb40d52c8c0/datafusion/common/src/utils/mod.rs#L260-L280
   
   This function doesn't always quote the identifier. Only quote it if it 
contains invalid characters, such as a dot, bracket, or uppercase letter.



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to