PHOENIX-7930: Address review feedback for EXPLAIN improvements#2537
Merged
Conversation
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR addresses review feedback around Phoenix EXPLAIN improvements by preventing shared mutable state during compilation, hardening ExplainPlanAttributes immutability, and tightening functional-index optimizer rule assertions in tests.
Changes:
- Deep-copy rewrite/diagnostic state in
StatementContext(copy ctor +adoptRewriteState) to avoid shared mutable collections. - Wrap remaining mutable
ExplainPlanAttributesfields (serverMergeColumns,subPlans,regionLocations) with unmodifiable wrappers. - Remove broad exception swallowing in
ExplainTableand update tests/utilities to assert functional-index rule labels viaOptimizerReasons.matches(...).
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTestUtil.java | Adds indexRuleMatches() helper using OptimizerReasons.matches() for exact rule-label assertions. |
| phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java | Updates functional-index rule assertion to use indexRuleMatches(). |
| phoenix-core/src/it/java/org/apache/phoenix/end2end/json/JsonFunctionsIT.java | Tightens plan assertion to match exact functional-index rule label. |
| phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexUsageIT.java | Restores/improves functional-index assertions using exact match helper across multiple ITs. |
| phoenix-core-client/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java | Removes a stray semicolon. |
| phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.java | Removes catch (Exception) + logging and keeps region location formatting/attributes setting. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/UnionCompiler.java | Records UNION ORDER BY MERGE breadcrumb on the real (outer) compilation context. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.java | Implements deep(ish) copy of rewrite/diagnostic collections to avoid shared mutable state. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/QueryCompiler.java | Passes the outer compilation context into UnionCompiler for breadcrumb recording. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainPlanAttributes.java | Wraps previously-mutable collections in unmodifiable wrappers to prevent post-build mutation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
virajjasani
approved these changes
Jun 17, 2026
…te copy semantics.
apurtell
added a commit
to apurtell/phoenix
that referenced
this pull request
Jun 17, 2026
…e#2537) Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Address review feedback for EXPLAIN improvements
StatementContext.adoptRewriteStateshares mutable collections by reference. HaveadoptRewriteStateand the copy constructor allocate fresh collections.ExplainPlanAttributes,serverMergeColumns,subPlans, andregionLocationsare the only fields not wrapped withCollections.unmodifiableX(...). Callers can mutate after build, silently corrupting EXPLAIN JSON. Wrap these three fields the same way the others are wrapped.ExceptioninExplainTable. Remove now unused SLF4J imports.Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com