Skip to content

feat(planner): Improve TextRenderer to show input totals#27189

Merged
tdcmeehan merged 1 commit intoprestodb:masterfrom
aaneja:improveJoinNodeSummary
Feb 24, 2026
Merged

feat(planner): Improve TextRenderer to show input totals#27189
tdcmeehan merged 1 commit intoprestodb:masterfrom
aaneja:improveJoinNodeSummary

Conversation

@aaneja
Copy link
Copy Markdown
Contributor

@aaneja aaneja commented Feb 23, 2026

Description, Motivation and Context

This makes it much easier to gork what a nodes input were (especially for join nodes)
An example -

- InnerJoin[PlanNodeId 2455][("suppkey_16" = "suppkey_21")] => [partkey_15:bigint, supplycost_18:double]
                 Estimates: {source: CostBasedSourceInfo, rows: 1,600 (28.13kB), cpu: 684,460.00, memory: 225.00, network: 234.00}
                 CPU: 11.00ms (6.40%), Scheduled: 13.00ms (1.77%), Output: 1,600 rows (40.63kB)
                 Left (probe) Input total: 8,000 rows (210.94kB), avg.: 2,000.00 rows, std.dev.: 0.00%
                 Right (build) Input total: 20 rows (260B), avg.: 1.25 rows, std.dev.: 60.00%
                         Collisions avg.: 0.40 (30.84% est.), Collisions std.dev.: 183.71%
                 Distribution: REPLICATED

Test Plan

CI

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

Summary by Sourcery

Enhance plan text rendering to include total input row counts and data sizes alongside existing input distribution statistics for operators in EXPLAIN ANALYZE output.

New Features:

  • Add tracking of input data size to operator input statistics and propagate it through plan node statistics summarization.
  • Display per-operator total input rows and input data size in the text plan renderer to improve readability of join and other node inputs.

This makes it much easier to gork what a nodes input were
(especially for join nodes)
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Feb 23, 2026
@prestodb-ci prestodb-ci requested review from a team, BryanCutler and jkhaliqi and removed request for a team February 23, 2026 08:09
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Feb 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Extends operator input statistics to track total input data size in bytes and updates the text plan renderer to display per-operator input totals (rows and size) alongside averages and standard deviations in EXPLAIN ANALYZE output, wiring the new metric through the plan stats summarization pipeline.

Sequence diagram for EXPLAIN ANALYZE input totals propagation

sequenceDiagram
    actor User
    participant PrestoClient
    participant Coordinator
    participant TaskStats
    participant PlanNodeStatsSummarizer
    participant PlanNodeStats
    participant TextRenderer

    User->>PrestoClient: Run EXPLAIN_ANALYZE query
    PrestoClient->>Coordinator: Submit query
    Coordinator->>TaskStats: Collect operator level stats
    TaskStats-->>Coordinator: OperatorStats (including inputDataSizeInBytes)

    Coordinator->>PlanNodeStatsSummarizer: getPlanNodeStats(taskStats)
    PlanNodeStatsSummarizer->>PlanNodeStatsSummarizer: Build OperatorInputStats
    PlanNodeStatsSummarizer->>PlanNodeStats: Create per plan node stats
    PlanNodeStats-->>Coordinator: PlanNodeStats list

    Coordinator->>TextRenderer: Render textual plan
    TextRenderer->>PlanNodeStats: getOperatorInputStats()
    TextRenderer->>PlanNodeStats: getOperatorInputPositionsAverages()
    TextRenderer->>PlanNodeStats: getOperatorInputPositionsStdDevs()
    TextRenderer->>TextRenderer: For each operator
    TextRenderer-->>PrestoClient: Text plan with Input total rows and bytes
    PrestoClient-->>User: Display plan output
Loading

Class diagram for updated operator input statistics and text rendering

classDiagram
    class OperatorStats {
        +long getTotalDrivers()
        +long getInputPositions()
        +long getInputDataSizeInBytes()
        +double getSumSquaredInputPositions()
    }

    class OperatorInputStats {
        -long totalDrivers
        -long inputPositions
        -long inputDataSizeInBytes
        -double sumSquaredInputPositions
        +OperatorInputStats(long totalDrivers, long inputPositions, long inputDataSizeInBytes, double sumSquaredInputPositions)
        +long getTotalDrivers()
        +long getInputPositions()
        +long getInputDataSizeInBytes()
        +double getSumSquaredInputPositions()
        +static OperatorInputStats merge(OperatorInputStats first, OperatorInputStats second)
    }

    class PlanNodeStats {
        +Map~String, Double~ getOperatorInputPositionsAverages()
        +Map~String, Double~ getOperatorInputPositionsStdDevs()
        +Map~String, OperatorInputStats~ getOperatorInputStats()
    }

    class PlanNodeStatsSummarizer {
        +static List~PlanNodeStats~ getPlanNodeStats(TaskStats taskStats)
    }

    class TextRenderer {
        -void printDistributions(StringBuilder output, PlanNodeStats stats)
    }

    class TaskStats {
        +List~OperatorStats~ getOperatorSummaries()
    }

    OperatorStats --> OperatorInputStats : builds
    TaskStats --> PlanNodeStatsSummarizer : input
    PlanNodeStatsSummarizer --> PlanNodeStats : produces
    PlanNodeStatsSummarizer --> OperatorInputStats : aggregates
    PlanNodeStats --> OperatorInputStats : exposes via map
    TextRenderer --> PlanNodeStats : reads stats
    TextRenderer --> OperatorInputStats : reads inputPositions
    TextRenderer --> OperatorInputStats : reads inputDataSizeInBytes
Loading

File-Level Changes

Change Details Files
Track input data size in operator input statistics and support JSON serialization/aggregation.
  • Add inputDataSizeInBytes field to operator input statistics data class.
  • Expose getter and JSON property for the new input data size metric.
  • Update merge logic to sum input data size when combining operator input stats.
presto-main-base/src/main/java/com/facebook/presto/sql/planner/planPrinter/OperatorInputStats.java
Render input totals (rows and bytes) for each operator in textual plan output.
  • Retrieve full OperatorInputStats map in the text renderer alongside existing averages and standard deviations.
  • Compute total input row count and total input data size in bytes per operator.
  • Change distribution output format line to include input totals and human-readable data size before averages and standard deviation.
presto-main-base/src/main/java/com/facebook/presto/sql/planner/planPrinter/TextRenderer.java
Wire operator input data size into plan node stats summarization.
  • Construct OperatorInputStats instances with input data size populated from operator stats.
  • Ensure map-merging logic uses the updated OperatorInputStats.merge implementation so aggregated stats include data size.
presto-main-base/src/main/java/com/facebook/presto/sql/planner/planPrinter/PlanNodeStatsSummarizer.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In TextRenderer.printDistributions, inputStats.get(operator) is used without a null check; consider handling the case where input stats might be absent for an operator to avoid potential NPEs.
  • The computation of std.dev. assumes inputAverage > 0; guard against zero or extremely small inputAverage to avoid division-by-zero and unintuitive Infinity/NaN output.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `TextRenderer.printDistributions`, `inputStats.get(operator)` is used without a null check; consider handling the case where input stats might be absent for an operator to avoid potential NPEs.
- The computation of `std.dev.` assumes `inputAverage > 0`; guard against zero or extremely small `inputAverage` to avoid division-by-zero and unintuitive `Infinity`/`NaN` output.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (docs)

Pull updated branch, new local doc build, looks good. Thanks!

@tdcmeehan tdcmeehan merged commit e72544f into prestodb:master Feb 24, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants