QuakeWang opened a new issue, #27164:
URL: https://github.com/apache/datafusion/issues/27164

   ### Describe the bug
   
   In DataFusion 55.2.0, `DELETE FROM target AS d WHERE d.id = 1` fails during 
logical planning because `d.id` cannot be resolved.
   
   The equivalent SELECT works. DELETE also plans successfully when the 
predicate uses the unqualified column `id`.
   
   ### To Reproduce
   
   ```sql
   CREATE TABLE target AS SELECT 1 AS id;
   
   SELECT d.id FROM target AS d WHERE d.id = 1;
   
   DELETE FROM target AS d WHERE d.id = 1;
   ```
   
   The DELETE statement fails with:
   
   ```text
   Schema error: No field named d.id. Did you mean 'target.id'?
   ```
   
   ### Expected behavior
   
   Resolve `d` as the target table alias, delete the row where `id = 1`, and 
return `count = 1`.
   
   ### Additional context
   
   `get_delete_target()` extracts only `name` from `TableFactor::Table`, 
discarding the alias. `delete_to_plan()` then builds a schema qualified by the 
actual table name, so `d.id` cannot be resolved. The failure occurs before 
`TableProvider::delete_from` is called.
   
   Reproduced on 55.2.0. The same alias handling was present on `main` when 
inspected, but the reproducer has not been run against `main`.
   
   This issue concerns target alias resolution for single-table DELETE.
   
   ### Willingness to contribute
   
   I plan to contribute a fix for this bug independently.
   


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