jiwen624 opened a new pull request, #27844:
URL: https://github.com/apache/datafusion/pull/27844

   ## Which issue does this PR close?
   
   - Closes https://github.com/apache/datafusion/issues/27843.
   
   ## Rationale for this change
   With the default setting `datafusion.sql_parser.enable_ident_normalization = 
true`, unquoted target column names in the `REPLACE`, `EXCLUDE` and `EXCEPT` 
options of `SELECT *`  are not normalized to lowercase.
   
   For a table with a lowercase column `col1`, using unquoted `COL1` causes 
`REPLACE` to silently leave the column unchanged, while `EXCLUDE` and `EXCEPT` 
fail with a schema error:
   ```SQL
   CREATE TABLE t (col1 INT, col2 VARCHAR) AS VALUES (1, 'a'), (2, 'b');
   
   SELECT * REPLACE (col1 + 1 AS COL1) FROM t;  -- col1 = 1, 2 (expected 2, 3)
   SELECT * EXCLUDE (COL1) FROM t;              -- Schema error: No field named 
"COL1"
   SELECT * EXCEPT (COL1) FROM t;               -- Schema error: No field named 
"COL1"
   ```
   This is the same gap #27808 fixed for PARTITIONED BY.
   
   ## What changes are included in this PR?
   `plan_wildcard_options` normalizes the `EXCLUDE`, `EXCEPT` and `REPLACE` 
column names with the planner's `IdentNormalizer`, so 
`enable_ident_normalization = false` keeps the current case-sensitive behavior.
   
   ## What is the testing strategy for this PR?
   New cases in select.slt for each option with unquoted uppercase names, which 
fail on main, and one with a quoted mixed-case name to check it is not 
lowercased.
   
   ## Are there any user-facing changes?
   Yes. REPLACE, EXCLUDE and EXCEPT now treat unquoted column names 
case-insensitively, like the rest of the query. Quoted names are unchanged.


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