apache / apache/datafusion

CREATE TABLE succeeds when schema has duplicate names, resulting in a table that cannot be selected from

Open
#13,487 1 comment 0 reactions 1 assignee Claimed by @findepi View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

CREATE TABLE succeeds when schema has duplicate names, resulting in a table that cannot be selected from

### To Reproduce

```
> CREATE TABLE t AS SELECT * FROM (SELECT 1 AS id, 'Foo' AS name) l JOIN (SELECT 1 AS id, 'Bar' as name) r ON l.id = r.id;
0 row(s) fetched.
Elapsed 0.016 seconds.

> SELECT * FROM t;
Schema error: Schema contains duplicate qualified field name t.id

> SELECT count(*) FROM t;
Schema error: Schema contains duplicate qualified field name t.id
```

### Expected behavior

If `CREATE TABLE` succeeds, the table should be readable.
If the table is not going to be readable (and we know this at create time), the `CREATE TABLE` should fail.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.