-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Execute below sqls in datafusion-cli
create table t (a int);
select max(a) as a1, max(cast(a, bigint)) as a2 from t;
will get error: Schema error: Schema contains duplicate unqualified field name "max(t.a)". I tried in postgres and it won't fail.
I've found root cause. it's due to aggregate plan output schema building.
datafusion/datafusion/expr/src/logical_plan/plan.rs
Lines 3492 to 3497 in 5258352
| qualified_fields.extend(exprlist_to_fields(aggr_expr.as_slice(), &input)?); | |
| let schema = DFSchema::new_with_metadata( | |
| qualified_fields, | |
| input.schema().metadata().clone(), | |
| )?; |
datafusion/datafusion/expr/src/expr.rs
Lines 2799 to 2802 in 5258352
| // Cast expr is not shown to be consistent with Postgres and Spark <https://github.com/apache/datafusion/pull/3222> | |
| Expr::Cast(Cast { expr, .. }) | Expr::TryCast(TryCast { expr, .. }) => { | |
| write!(f, "{}", SchemaDisplay(expr)) | |
| } |
But the comment says
Cast expr is not shown to be consistent with Postgres and Spark. So I don't know what is the right fix.
To Reproduce
No response
Expected behavior
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working