Skip to content

PHOENIX-7922 Consolidate the EXPLAIN rewrite pass entry points - #2529

Merged
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7922
Jun 14, 2026
Merged

PHOENIX-7922 Consolidate the EXPLAIN rewrite pass entry points#2529
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7922

Conversation

@apurtell

Copy link
Copy Markdown
Contributor

Consolidate the rewrite pass entry points.

Add forRewrite() on StatementContext, carrying rewrite breadcrumbs across the early rewrite pass at four call sites (PhoenixStatement.ExecutableSelectStatement.compilePlan, DeleteCompiler.compile, UpsertCompiler.compile, and QueryCompiler.compileSubquery). The bespoke BindManager and FromCompiler additions in PhoenixStatement and DeleteCompiler go away. Drops the legacy single argument rewriter overloads SubselectRewriter.flatten(SelectStatement, PhoenixConnection) and SubqueryRewriter.transform(SelectStatement, ColumnResolver, PhoenixConnection) plus the matching 3-arg new SubqueryRewriter(...) constructor. The four legacy overloads are deleted, and the trivial forwarding layer goes with them.

No behavior change. EXPLAIN text and JSON output are unchanged.

Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com

Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates the early EXPLAIN rewrite-pass entry points by introducing StatementContext.forRewrite(...) and updating key compilation call sites to reuse a consistent rewrite context for breadcrumb accumulation, while removing now-redundant legacy overloads.

Changes:

  • Added StatementContext.forRewrite(...) factory methods to standardize creation of rewrite-pass contexts (including a variant that reuses an existing BindManager).
  • Updated rewrite-pass call sites in PhoenixStatement, QueryCompiler, UpsertCompiler, DeleteCompiler, and a test helper to pass an explicit rewrite context.
  • Removed legacy SubselectRewriter.flatten(...) and SubqueryRewriter.transform(...) overloads (and a forwarding constructor) that previously defaulted to null context.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java Updates test helper to create and pass a rewrite StatementContext through flatten/transform.
phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java Switches to StatementContext.forRewrite(...) for top-level rewrite-pass context creation.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java Uses StatementContext.forRewrite(...) for UPSERT SELECT rewrite-pass context creation.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java Removes legacy 2-arg flatten(...) overload; callers must pass context (or null) explicitly.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.java Removes legacy 3-arg transform(...) overload and a forwarding constructor; explicit context required.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.java Introduces forRewrite(...) factory methods to standardize rewrite context construction.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/QueryCompiler.java Replaces bespoke rewrite-context construction with StatementContext.forRewrite(statement, bindManager).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@apurtell

Copy link
Copy Markdown
Contributor Author

Test Results

Unit tests

Aggregate: tests run = 2640, skipped = 9.

Compile-pass tests directly exercising the patch

Test class Tests run / pass Time
org.apache.phoenix.query.explain.ExplainPlanTest 105 / 105 0.78 s
org.apache.phoenix.compile.QueryCompilerTest 215 / 215 (2 sk) 1.49 s
org.apache.phoenix.compile.JoinQueryCompilerTest 2 / 2 0.09 s
org.apache.phoenix.compile.HavingCompilerTest 11 / 11 0.22 s
org.apache.phoenix.compile.RVCOffsetCompilerTest 7 / 7 0.03 s
org.apache.phoenix.compile.WhereOptimizerTest 138 / 138 4.95 s

Integration tests

The patch touches the four early rewrite-pass entry points (SELECT, DELETE, UPSERT SELECT, subquery in QueryCompiler) and the test-only getJoinTable utility. The IT classes below cover all of them and the EXPLAIN baseline.

IT class Tests run / pass Time
org.apache.phoenix.end2end.ExplainPlanWithStatsEnabledIT 30 / 30 45.9 s
org.apache.phoenix.end2end.ExplainPlanWithStatsDisabledIT 17 / 17 36.8 s
org.apache.phoenix.end2end.DerivedTableIT 18 / 18 50.0 s
org.apache.phoenix.end2end.join.SubqueryIT 36 / 36 204.7 s
org.apache.phoenix.end2end.RowValueConstructorOffsetIT 33 / 33 38.7 s
org.apache.phoenix.end2end.SortMergeJoinMoreIT 10 / 10 62.5 s
org.apache.phoenix.end2end.DeleteIT 74 / 74 201.7 s
org.apache.phoenix.end2end.UpsertSelectIT 54 / 54 204.3 s

@apurtell
apurtell merged commit be046f9 into apache:PHOENIX-7876-feature Jun 14, 2026
@apurtell
apurtell deleted the PHOENIX-7922 branch June 14, 2026 04:59
apurtell added a commit to apurtell/phoenix that referenced this pull request Jun 17, 2026
…e#2529)

Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
asf-gitbox-commits pushed a commit that referenced this pull request Jul 24, 2026
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
apurtell added a commit to apurtell/phoenix that referenced this pull request Aug 4, 2026
…e#2529)

Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants