GaneshPatil7517 opened a new pull request, #19693:
URL: https://github.com/apache/datafusion/pull/19693
## Which issue does this PR close?
Closes #19685
## Rationale for this change
When an aggregate expression has been aliased, the logical plan `EXPLAIN`
shows both the alias and the original expression. However, the physical plan
`EXPLAIN` only showed the alias name, making plans hard to interpret.
**Before:**
AggregateExec: mode=Single, gby=[], aggr=[agg]
AggregateExec: mode=Single, gby=[], aggr=[sum(column1@0) FILTER (WHERE
column2@1 <= Int64(0)) as agg]
## What changes are included in this PR?
1. **`datafusion/core/src/physical_planner.rs`**: Modified
`create_aggregate_expr_and_maybe_filter()` to use the unaliased expression for
`human_display`, so it captures the actual aggregate expression instead of just
the alias name.
2. **`datafusion/physical-plan/src/aggregates/mod.rs`**: Modified
`DisplayAs` impl for `AggregateExec` to show both the expression
(`human_display`) and alias (`name()`) when they differ, in the format
`{expression} as {alias}`.
3. **Test file updates**: Updated test expectations in `explain.slt`,
`aggregate.slt`, and `agg_func_substitute.slt` to reflect the new output format.
## Are these changes tested?
Yes. Added new test cases in `explain.slt` that specifically verify aliased
aggregate expressions are visible in physical EXPLAIN output. Updated existing
test expectations in `aggregate.slt` and `agg_func_substitute.slt`.
## Are there any user-facing changes?
Yes. The physical plan `EXPLAIN` output now shows the full aggregate
expression along with its alias when they differ, improving plan readability
and debuggability.
--
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]