va24nsh opened a new pull request, #18570:
URL: https://github.com/apache/datafusion/pull/18570
## Which issue does this PR close?
- First Part of #18456
## Rationale for this change
Currently, `EXPLAIN ANALYZE` for `ProjectionExec` only shows aggregated
metrics like total elapsed compute time, but doesn't provide visibility into
how much time individual expressions within the projection consume. This makes
it difficult to identify performance bottlenecks when debugging slow queries
with complex projection expressions.
## What changes are included in this PR?
**1. Enhanced `ProjectionExec` with per-expression timing metrics:**
- Added per-expression Time metrics collection in `ProjectionStream`
- Each projection expression gets its own timer using the expression
alias as the metric name
- Metrics are properly registered with the execution plan's metrics set
**2. Extended metrics display in `EXPLAIN ANALYZE`:**
- Modified `display.rs` to detect ProjectionExec plans
- Added `get_projection_expr_metrics()` helper function to extract
per-expression timing data
- Enhanced metrics output to include per-expression times alongside
standard metrics
**3. Added intelligent time formatting:**
- Implemented proper time unit formatting (ns, μs, ms, s) based on
duration magnitude
- Maintains consistency with DataFusion's existing time formatting
standards
## Are these changes tested?
**Yes** - The tests have been added to check the proper functionality of
latest functions.
## Are there any user-facing changes?
**Yes** - This is an enhancement to the existing `EXPLAIN ANALYZE`
functionality
--
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]