Skip to content

PHOENIX-7918 Implement EXPLAIN VERBOSE disclosures - #2526

Merged
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7918
Jun 13, 2026
Merged

PHOENIX-7918 Implement EXPLAIN VERBOSE disclosures#2526
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7918

Conversation

@apurtell

@apurtellapurtell commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

EXPLAIN VERBOSE implements VERBOSE-gated disclosures for projections, predicate origin attribution on SERVER FILTER BY / CLIENT FILTER BY, and ignored hint comments.

The verbose flag is threaded from ExplainOptions onto StatementContext. ExplainPlanAttributes.serverProject : List<String> is populated from plan.getProjector().getColumnProjectors(). ExplainPlanAttributes also adds serverFilters : List<ExplainFilter>.

The per-scan /* !INDEX <name> -- <reason> */ text is now gated on verbose.

The chosen-plan INDEX <name> [<kind>] /* <rule> */ line stays in plain EXPLAIN and indexRejected populates in both modes.

StatementContext adds predicateOrigins, populated by WhereCompiler, HavingCompiler, JoinCompiler, IndexStatementRewriter, and RVCOffsetCompiler.

Under VERBOSE a fully-tagged AndExpression fans out to one SERVER FILTER BY (<child>) -- <child-origin> per child, otherwise a single line carries the comma-separated union.

JsonExistsFunction / BsonConditionExpressionFunction append (JSON EXISTS) / (BSON CONDITION).

For ignored hints StatementContext adds Map<Hint, IgnoredHintReason> populated at Hint.NO_INDEX, Hint.USE_SORT_MERGE_JOIN, and Hint.SMALL. Under VERBOSE ExplainTable emits one /*- HINT(args) -- <reason> */ per ignored hint, including partially honored hints.

The symmetric clientFilters : List<ExplainFilter> collects every CLIENT FILTER BY site in ClientScanPlan, ClientAggregatePlan, FilterResultIterator, FilterAggregatingResultIterator, and TupleProjectionPlan.

ExplainPlanTestUtil adds fluent getters, setters, and testers. ExplainJsonNormalizer recurses serverFilters / clientFilters.

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

CopilotAI 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 adds EXPLAIN VERBOSE support across Phoenix’s planning/explain pipeline, introducing VERBOSE-gated disclosures (server projection columns, per-predicate filter attribution, and ignored hints) while keeping plain EXPLAIN output stable.

Changes:

  • Thread a verbose flag from ExplainOptions into StatementContext, and collect diagnostic metadata (predicate origins + ignored hints) during compilation/optimization.
  • Extend ExplainTable and several client-side plans/iterators to emit VERBOSE-only disclosures (PROJECT, per-predicate SERVER/CLIENT FILTER BY … -- <origin>, and ignored-hint comments).
  • Expand ExplainPlanAttributes (and test utilities/normalizers) to carry structured serverProject, serverFilters, clientFilters, and ignoredHints.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTestUtil.javaAdds VERBOSE-focused assertion helpers and a plan-step getter that applies ExplainOptions.
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.javaAdds/updates tests covering VERBOSE-only disclosures and gating behavior.
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainJsonNormalizer.javaNormalizes temp aliases inside serverFilters/clientFilters[*].expr for stable JSON comparisons.
phoenix-core-client/src/main/java/org/apache/phoenix/schema/PTableImpl.javaTags partial-index WHERE predicates with an origin for VERBOSE attribution.
phoenix-core-client/src/main/java/org/apache/phoenix/parse/ExplainOptions.javaAdds ExplainOptions.VERBOSE.
phoenix-core-client/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.javaRecords ignored hints (e.g., NO_INDEX, INDEX(...)) and carries them forward between candidate plans.
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/FilterResultIterator.javaAdds VERBOSE client-filter breakdown emission and structured clientFilters population.
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/FilterAggregatingResultIterator.javaSame as above for HAVING/post-aggregate client filters.
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.javaImplements VERBOSE-only PROJECT, !INDEX gating, ignored-hint disclosures, and per-predicate server-filter breakdown rendering.
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.javaExposes the plan’s RowProjector to ExplainTable for VERBOSE PROJECT emission.
phoenix-core-client/src/main/java/org/apache/phoenix/execute/TupleProjectionPlan.javaEmits VERBOSE client-filter breakdown for post-filters and passes context to runtime filter iterator.
phoenix-core-client/src/main/java/org/apache/phoenix/execute/HashJoinPlan.javaPasses StatementContext into FilterResultIterator so VERBOSE client filter breakdown is available.
phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientScanPlan.javaEmits VERBOSE client-filter breakdown + structured clientFilters; passes context into runtime filter iterator.
phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.javaEmits VERBOSE client-filter breakdown for WHERE/HAVING and wires context through filter iterators.
phoenix-core-client/src/main/java/org/apache/phoenix/execute/AggregatePlan.javaWires context through HAVING filter iterator for VERBOSE attribution.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/WhereCompiler.javaTags residual WHERE predicate conjuncts with "WHERE" origins for VERBOSE attribution.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/SubqueryRewriter.javaPlumbs StatementContext into decorrelation so JOIN-origin attribution can mention decorrelated subquery aliases.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/StatementContext.javaAdds VERBOSE plumbing: isVerbose(), predicate-origin tagging/unioning, lifted-HAVING tracking, decorrelated alias mapping, and ignored-hint recording.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/RVCOffsetCompiler.javaTags the RVC offset predicate with origin "RVC OFFSET" for VERBOSE attribution.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/QueryCompiler.javaRecords ignored USE_SORT_MERGE_JOIN when no join exists.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/JoinCompiler.javaTags compiled ON predicates with "JOIN ON" or a decorrelation-based origin string.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/HavingCompiler.javaTags HAVING residual predicates with "HAVING" origins and records which nodes were lifted into WHERE.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainPlanAttributes.javaAdds structured VERBOSE attributes (serverProject, serverFilters, clientFilters, ignoredHints) plus a filter element type.

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

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

Copy link
Copy Markdown
ContributorAuthor

Amended with review feedback.

@apurtell

Copy link
Copy Markdown
ContributorAuthor

Test Results

Unit Tests (*Test)

ModuleTestsFailuresErrorsSkippedResult
phoenix-core-client0000no unit tests in module
phoenix-core2608009PASS
phoenix-pherf60110pre-existing failures (see below)
phoenix-tracing-webapp0000no unit tests in module

Integration Tests (*IT) — impacted set

IT classTouched class exercisedTestsFailErrResult
ExplainPlanWithStatsEnabledITExplainTable / ExplainPlanAttributes (plain EXPLAIN)3000PASS
ExplainPlanWithStatsDisabledITExplainTable / ExplainPlanAttributes (plain EXPLAIN)1700PASS
AggregateITAggregatePlan + FilterAggregatingResultIterator (HAVING)2500PASS
GroupByITAggregatePlan / group-by + HAVING7000PASS
ClientHashAggregateITClientAggregatePlan (client WHERE + HAVING)200PASS
DerivedTableITClientScanPlan / TupleProjectionPlan post-filter1800PASS
SubqueryITSubqueryRewriter decorrelation + HashJoinPlan post-filter3600PASS
RowValueConstructorOffsetITRVCOffsetCompiler predicate tagging3300PASS
Total23100PASS

@apurtell
apurtell merged commit d18b98c into apache:PHOENIX-7876-featureJun 13, 2026
@apurtell
apurtell deleted the PHOENIX-7918 branch June 13, 2026 06:10
apurtell added a commit to apurtell/phoenix that referenced this pull request Jun 17, 2026
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
Co-authored-by: Claude Opus 4.8[1m] <noreply@anthropic.com>
Sign up for freeto 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

@apurtell