nantunes opened a new issue, #14583:
URL: https://github.com/apache/datafusion/issues/14583
### Describe the bug
When executing a DELETE statement with a case-sensitive quoted table name,
the table name is incorrectly normalized to lowercase, causing "table not
found" errors.
- The table name is normalized to lowercase when building the table scan
- This causes the table lookup to fail since the actual table name is
case-sensitive
- The logical plan shows the correct case in the DML node but lowercase in
the scan
### To Reproduce
```
$ delete from "MyTable" where id = '24bc45da-e00a-40bb-9f68-651b19450121'
❌ Client specified an invalid argument: Error during planning: table
'catalog.public.mytable' not found
$ explain delete from "MyTable" where id =
'24bc45da-e00a-40bb-9f68-651b19450121'
+---------------------+--------------------------------------------------------------------+
| plan_type | plan
|
+---------------------+--------------------------------------------------------------------+
| logical_plan | Dml: op=[Delete] table=[catalog.public.MyTable]
|
| | Filter: entity_id =
Utf8("24bc45da-e00a-40bb-9f68-651b19450121") |
| | TableScan: catalog.public.mytable
|
+---------------------+--------------------------------------------------------------------+
```
### Expected behavior
- The DELETE statement should preserve case sensitivity of quoted identifiers
- The table scan should use the exact table name as specified in quotes
- The query should execute successfully against case-sensitive table names
```
$ delete from "MyTable" where id = '24bc45da-e00a-40bb-9f68-651b19450121'
✅ Ok (1 rows affected)
$ explain delete from "MyTable" where id =
'24bc45da-e00a-40bb-9f68-651b19450121'
+---------------------+--------------------------------------------------------------------+
| plan_type | plan
|
+---------------------+--------------------------------------------------------------------+
| logical_plan | Dml: op=[Delete] table=[catalog.public.MyTable]
|
| | Filter: entity_id =
Utf8("24bc45da-e00a-40bb-9f68-651b19450121") |
| | TableScan: catalog.public.MyTable
|
+---------------------+--------------------------------------------------------------------+
```
### Additional context
The issue was introduced in
[8b716d3](https://github.com/apache/datafusion/commit/8b716d398b9626b5d1ccd7105e588431931ad25a#diff-bb98aeaec478d9576e33911f252745961f57e38d25f6e9d13803894dfbad25d5L614).
When building the table scan for DELETE statements, the table name is passed
as a string to `LogicalPlanBuilder::scan()`. This string is then treated as a
SQL identifier and normalized again, losing case sensitivity.
The table name should be passed as an already normalized `TableReference`
instead of re-converting it to a string again.
--
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]