You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Table names with periods are not handled correctly #4513
Describe the bug
We have a customer with a table whose name contains a period
In SQL you can refer to such tables using double quotes "foo.bar". Note this is different than foo.bar which means table named bar in the schema named foo.
You can see how this works in postgres:
postgres=# create table "foo.bar" as values (1), (2);SELECT2
postgres=# select * from foo.bar;
ERROR: relation "foo.bar" does not exist
LINE1: select*fromfoo.bar;
^
postgres=# select * from "foo.bar";
column1
---------12
(2 rows)
postgres=# \d foo.bar
Did not find any relation named "foo.bar".
postgres=# \d "foo.bar"
Table "public.foo.bar"
Column | Type | Collation | Nullable | Default
---------+---------+-----------+----------+---------
column1 | integer | | |
**To Reproduce**
Try to create (or query) tables with double quotes:
From the error message it is clear that DataFusion is treating `"foo.bar"`as schema named `foo` table named `bar````sql❯ select * from "foo.bar";Plan("failed to resolve schema: foo")❯ select * from foo.bar;Plan("failed to resolve schema: foo")
Activity
[-]Table names with periods are not supported correctly[/-][+]Table names with periods are not handled correctly[/+]alamb commentedon Dec 5, 2022
I believe the issue is that this code does not handle
"properly: https://github.com/apache/arrow-datafusion/blob/740a4fa2c6ba4b85875a433bb86e5b00435a5969/datafusion/common/src/table_reference.rs#L97alamb commentedon Dec 6, 2022
I am actively working on this issue
waitingkuo commentedon Dec 6, 2022
hi @alamb
i tried to add this
to return the whole double quoted string before
let parts: Vec<&str> = s.split('.').collect();and it works while creating a new table
but failed to select it
waitingkuo commentedon Dec 6, 2022
@alamb
i also tested the single quoted string
i'm not sure whether this is expected
as postgresql doesn't support it
alamb commentedon Dec 6, 2022
I have a fix for this partially coded -- I'll get it up shortly
alamb commentedon Dec 6, 2022
Proposed PR to fix: #4530