apache / apache/datafusion

Failed to project when items contain expr and Cast(expr)

Open
#4,478 4 comments 0 reactions 0 assignees 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**
When I want to project column and the result of its type coercion, datafusion will throw error:
```sql
❯ select a, cast(a as Int) from test0;
Plan("Projections require unique expression names but the expression \"test0.a\" at position 0 and \"CAST(test0.a AS Int32)\" at position 3 have the same name. Consider aliasing (\"AS\") one of them.")
```
**To Reproduce**
Run projection with expression and its cast-wrapped expression.

**Expected behavior**

**Additional context**

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported SQL query `select a, cast(a as Int) from test0` in DataFusion and trace the projection-planning path that reports duplicate expression names. No source file or test is named in the issue; completion criteria are not specified because the Expected behavior section is empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.