Skip to content

PHOENIX-7967 Contain explain diagnostic recording#2582

Open
apurtell wants to merge 2 commits into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7967
Open

PHOENIX-7967 Contain explain diagnostic recording#2582
apurtell wants to merge 2 commits into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7967

Conversation

@apurtell

Copy link
Copy Markdown
Contributor

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

Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
@apurtell
apurtell requested review from Copilot and palashc July 24, 2026 00:24
@apurtell

Copy link
Copy Markdown
Contributor Author

@palashc Your suggested change

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 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 collectDiagnostics flag on PhoenixStatement and snapshots it into StatementContext to 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.

@palashc

palashc commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@palashc palashc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 comment and InListIT test failures look relevant.

@apurtell
apurtell requested a review from palashc July 24, 2026 18:28

@palashc palashc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

3 participants