Skip to content

Conversation

@feilong-liu
Copy link
Contributor

@feilong-liu feilong-liu commented Dec 4, 2025

Description

As title, so that join prefilter can be used for plans which are changed after connector optimizations.

Motivation and Context

As in description

Impact

As in description

Test Plan

Existing unit tests

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 ==

@prestodb-ci prestodb-ci added the from:Meta PR from Meta label Dec 4, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 4, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reorders the JoinPrefilter optimizer in the planner pipeline so that it runs after the connector-specific iterative optimization phase instead of before, allowing it to apply to plans produced or transformed by connector optimizations.

Flow diagram for updated optimizer pipeline around JoinPrefilter

flowchart TD
    subgraph OptimizerPipeline
        direction TB
        InlineSqlFunctions[InlineSqlFunctions]
        IterativeConnector[IterativeOptimizer_connector_specific]
        SimplifyEmpty[SimplifyPlanWithEmptyInput]
        PruneUnref[PruneUnreferencedOutputs]
        JoinPrefilterOpt[JoinPrefilter]
        IterativePost[IterativeOptimizer_post_join_prefilter]
    end

    InlineSqlFunctions --> IterativeConnector
    IterativeConnector --> SimplifyEmpty
    SimplifyEmpty --> PruneUnref
    PruneUnref --> JoinPrefilterOpt
    JoinPrefilterOpt --> IterativePost

    classDef connector fill:#e3f2fd,stroke:#1e88e5,stroke-width:1px;
    classDef rule fill:#f1f8e9,stroke:#7cb342,stroke-width:1px;

    class IterativeConnector connector;
    class IterativePost connector;
    class InlineSqlFunctions,SimplifyEmpty,PruneUnref,JoinPrefilterOpt rule;
Loading

File-Level Changes

Change Details Files
Reposition JoinPrefilter in the optimization pipeline to execute after connector iterative optimizations and other cleanup passes.
  • Remove the JoinPrefilter optimizer from the earlier position in the PlanOptimizers constructor, where it previously ran before the connector-specific iterative optimizer.
  • Insert the JoinPrefilter optimizer later in the pipeline, after SimplifyPlanWithEmptyInput and PruneUnreferencedOutputs, so it can operate on plans transformed by connector optimizations and subsequent simplifications.
  • Ensure the overall optimizer sequence remains valid, preserving the existing iterative optimizer configuration and rule wiring while only changing the ordering of JoinPrefilter.
presto-main-base/src/main/java/com/facebook/presto/sql/planner/PlanOptimizers.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

@feilong-liu feilong-liu requested a review from kaikalur December 4, 2025 01:52
Copy link
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 there - I've reviewed your changes - here's some feedback:

  • Since optimizer ordering is subtle and easy to regress, consider adding a brief code comment near JoinPrefilter in PlanOptimizers explaining why it must run after connector optimizations and after SimplifyPlanWithEmptyInput/PruneUnreferencedOutputs.
  • Double-check whether JoinPrefilter depends on or affects any of the earlier iterative optimizers in this pipeline; if so, it might be worth explicitly enforcing or documenting assumptions about which transformations must precede it.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since optimizer ordering is subtle and easy to regress, consider adding a brief code comment near `JoinPrefilter` in `PlanOptimizers` explaining why it must run after connector optimizations and after `SimplifyPlanWithEmptyInput`/`PruneUnreferencedOutputs`.
- Double-check whether `JoinPrefilter` depends on or affects any of the earlier iterative optimizers in this pipeline; if so, it might be worth explicitly enforcing or documenting assumptions about which transformations must precede it.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:Meta PR from Meta

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants