PHOENIX-7922 Consolidate the EXPLAIN rewrite pass entry points - #2529
Conversation
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
There was a problem hiding this comment.
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 existingBindManager). - Updated rewrite-pass call sites in
PhoenixStatement,QueryCompiler,UpsertCompiler,DeleteCompiler, and a test helper to pass an explicit rewrite context. - Removed legacy
SubselectRewriter.flatten(...)andSubqueryRewriter.transform(...)overloads (and a forwarding constructor) that previously defaulted tonullcontext.
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.
Test ResultsUnit testsAggregate: tests run = 2640, skipped = 9. Compile-pass tests directly exercising the patch
Integration testsThe patch touches the four early rewrite-pass entry points (SELECT, DELETE, UPSERT SELECT, subquery in
|
…e#2529) Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
…e#2529) Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Consolidate the rewrite pass entry points.
Add
forRewrite()onStatementContext, carrying rewrite breadcrumbs across the early rewrite pass at four call sites (PhoenixStatement.ExecutableSelectStatement.compilePlan,DeleteCompiler.compile,UpsertCompiler.compile, andQueryCompiler.compileSubquery). The bespokeBindManagerandFromCompileradditions inPhoenixStatementandDeleteCompilergo away. Drops the legacy single argument rewriter overloadsSubselectRewriter.flatten(SelectStatement, PhoenixConnection)andSubqueryRewriter.transform(SelectStatement, ColumnResolver, PhoenixConnection)plus the matching 3-argnew 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