PHOENIX-7967 Contain explain diagnostic recording#2582
Open
apurtell wants to merge 2 commits into
Open
Conversation
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Contributor
Author
|
@palashc Your suggested change |
There was a problem hiding this comment.
Pull request overview
This PR contains compile-time diagnostic recording so it only runs for EXPLAIN (or when explicitly enabled in tests), reducing overhead for normal query compilation while preserving EXPLAIN VERBOSE attribution and optimizer decision reporting.
Changes:
- Introduces a
collectDiagnosticsflag onPhoenixStatementand snapshots it intoStatementContextto gate diagnostic-only recording. - Lazily allocates diagnostic maps/lists and no-ops diagnostic hooks (predicate origin tagging, breadcrumbs, ignored hints, rejected indexes) when recording is disabled.
- Updates test utilities and adds/adjusts tests to verify “plain compile = no diagnostics” vs “EXPLAIN-mode compile = diagnostics recorded”.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTestUtil.java | Adds helper to compile with diagnostics temporarily enabled so tests can assert on inner plan attributes consistently with real EXPLAIN. |
| phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.java | Updates an existing VERBOSE-origin test to enable diagnostics explicitly; adds tests asserting diagnostics are absent for plain compiles and present for EXPLAIN-style compiles. |
| phoenix-core/src/test/java/org/apache/phoenix/compile/QueryOptimizerTest.java | Enables diagnostic recording explicitly for a rewrite-state test now that diagnostics are off by default. |
| phoenix-core-client/src/main/java/org/apache/phoenix/schema/PTableImpl.java | Gates partial-index predicate origin tagging behind diagnostic recording. |
| phoenix-core-client/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java | Propagates/gates rewrite breadcrumbs and rejected-index capture based on diagnostic recording; avoids allocations/cost when disabled. |
| phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java | Adds collectDiagnostics flag and scopes it to EXPLAIN compilation via try/finally. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/WhereCompiler.java | Skips WHERE origin tagging entirely when diagnostic recording is disabled. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.java | Captures collectDiagnostics from the statement, gates recording APIs, and lazily allocates diagnostic-only maps. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/RVCOffsetCompiler.java | Gates RVC-offset predicate origin tagging behind diagnostic recording. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/JoinCompiler.java | Gates JOIN ON predicate origin tagging behind diagnostic recording. |
| phoenix-core-client/src/main/java/org/apache/phoenix/compile/HavingCompiler.java | Gates HAVING predicate origin tagging (and child iteration) behind diagnostic recording. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
palashc
requested changes
Jul 24, 2026
palashc
left a comment
Contributor
There was a problem hiding this comment.
1 comment and InListIT test failures look relevant.
palashc
approved these changes
Jul 24, 2026
palashc
left a comment
Contributor
There was a problem hiding this comment.
+1, pending build results
https://ci-hadoop.apache.org/job/Phoenix/job/Phoenix-PreCommit-GitHub-PR/job/PR-2582/2/
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.
Co-authored-by: Claude Opus 4.8[1m] noreply@anthropic.com