alamb commented on code in PR #20146:
URL: https://github.com/apache/datafusion/pull/20146#discussion_r2766048077
##########
datafusion/expr/src/expr_rewriter/mod.rs:
##########
@@ -261,9 +261,14 @@ fn coerce_exprs_for_schema(
#[expect(deprecated)]
Expr::Wildcard { .. } => Ok(expr),
_ => {
- // maintain the original name when casting
- let name = dst_schema.field(idx).name();
- Ok(expr.cast_to(new_type, src_schema)?.alias(name))
+ match expr {
+ // maintain the original name when casting a column
+ Expr::Column(ref column) => {
Review Comment:
can we add some context about why we maintain the original name only for
columns?
##########
datafusion/optimizer/tests/optimizer_integration.rs:
##########
@@ -543,7 +543,7 @@ fn recursive_cte_projection_pushdown() -> Result<()> {
RecursiveQuery: is_distinct=false
Projection: test.col_int32 AS id
TableScan: test projection=[col_int32]
- Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32) AS id
+ Projection: CAST(CAST(nodes.id AS Int64) + Int64(1) AS Int32)
Review Comment:
it isn't needed because the outer query doesn't use `id`?
--
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]