Skip to content

Add skewness metric to nodes that execute in partitioned mode (#25977) - #188

Merged
LiaCastaneda merged 1 commit into
branch-55from
lia/cherry-pick-skewness-metric
Oct 6, 2026
Merged

LiaCastaneda merged 1 commit into
branch-55from
lia/cherry-pick-skewness-metric

Conversation

@LiaCastaneda

Copy link
Copy Markdown

Cherry picks apache#25977

…#25977)

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->

Related to apache#23237 and
[feat(metric): Add output skewness metric to detect skewed plans
easier](apache#21211)

- Closes #.

I think it would be useful to add the skewness metric for nodes that
execute in partitioned mdoe -- right now the only node that includes
that metric in the explain analyze is DataSourceExec for parquet.

This is specially useful to check how many partitions were idle during
Aggregations or HashJoins for example.

The PR adds a new metric `output_rows_skew` in the Explain Analyze
output for the following nodes:

- RepartitionExec
- HashJoinExec
- AggregateExec
- BoundedWindowAggExec
- WindowAggExec

Note that for a plan that has a Parquet DataSource the skewness might
not be the same as for the rest of the nodes, for example we might have
the following scenario:

```
DataSourceExec       [100, 100, 100, 100]  → 0% skewness, data is even
  FilterExec         [100,   0,   0,   0]  → 100%   (filter only matches in partition 0)
    AggregateExec    [  3,   0,   0,   0]  → 100%   (Partial: groups, not rows)
      RepartitionExec Hash  [1, 1, 1, 0]   → ~11%   (3 groups re-spread by key)

```

I added a Explain Analyze test

Yes, a new metric will show in the explain analyze plan for the nodes
mentioned above.

(cherry picked from commit c2baac5)
@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.81818% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.19%. Comparing base (a358de8) to head (a78abf7).
⚠️ Report is 1 commits behind head on branch-55.

Files with missing lines Patch % Lines
datafusion/physical-expr-common/src/metrics/mod.rs 83.33% 0 Missing and 1 partial ⚠️
...usion/physical-plan/src/windows/window_agg_exec.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           branch-55     #188   +/-   ##
==========================================
  Coverage      81.19%   81.19%           
==========================================
  Files           1111     1111           
  Lines         387468   387474    +6     
  Branches      387468   387474    +6     
==========================================
+ Hits          314590   314608   +18     
+ Misses         54370    54364    -6     
+ Partials       18508    18502    -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LiaCastaneda
LiaCastaneda merged commit d0a9842 into branch-55 Oct 6, 2026
68 of 70 checks passed
@LiaCastaneda
LiaCastaneda deleted the lia/cherry-pick-skewness-metric branch October 6, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants