waynexia opened a new issue, #6853:
URL: https://github.com/apache/arrow-datafusion/issues/6853

   ### Describe the bug
   
   `to_string` simply concat components with `.`:
   
https://github.com/apache/arrow-datafusion/blob/02a470f6061cce8ee8e57f7af8a6a0e0ddc1571b/datafusion/common/src/table_reference.rs#L107-L121
   
   but `from_string` will transform them to lowercase:
   
https://github.com/apache/arrow-datafusion/blob/02a470f6061cce8ee8e57f7af8a6a0e0ddc1571b/datafusion/common/src/utils.rs#L248-L257
   
   `TableReference` is the most common table identifier for tables. But I don't 
think converting cases or considering quotes is necessary when the object name 
becomes `TableReference`. At this stage (i.e., after the initial plan is 
constructed from AST), those object names should be fixed.
   
   This implicit conversion makes it difficult when handling complex table 
identifiers. Thus I propose to make `TableReference` as simple as possible and 
gather all those `to_lower_cases` and "quotes" before generating the very first 
`TableReference`.
   
   ### To Reproduce
   
   ```rust
       #[test]
       fn to_lower_case() {
           let table_ref = TableReference::Full {
               catalog: Cow::Owned("catalog".to_string()),
               schema: Cow::Owned("schema".to_string()),
               table: Cow::Owned("TABLE".to_string()),
           };
           let concatted = table_ref.to_string();
           println!("concatted: {}", concatted);
           let parsed = TableReference::parse_str(&concatted);
           println!("parsed: {:?}", parsed.to_vec());
       }
   ```
   
   The output is
   ```
   concatted: catalog.schema.TABLE
   parsed: ["catalog", "schema", "table"]
   ```
   
   ### Expected behavior
   
   ```
   concatted: catalog.schema.TABLE
   parsed: ["catalog", "schema", "TABLE"]
   ```
   
   ### Additional context
   
   (Not sure if this is "bug"...)


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

Reply via email to