Skip to content

PHOENIX-7923 Simplify EXPLAIN value classes - #2530

Merged
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7923
Jun 14, 2026
Merged

PHOENIX-7923 Simplify EXPLAIN value classes#2530
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7923

Conversation

@apurtell

Copy link
Copy Markdown
Contributor

Simplify EXPLAIN value classes.

Replaces ExplainPlanAttributes' private zero args constructor and package private all args constructor with a private builder. Removes ExplainTable.RegionBoundary in favor of deduping HRegionLocations in getRegionLocationsForExplainPlan via a LinkedHashSet<String>. Replaces ExplainOptions.Builder's regionsSet / verboseSet companion booleans with an inline EnumSet<Option> in the grammar action. The nested Builder type goes away and the parser constructs ExplainOptions directly. No behavior change. EXPLAIN text and JSON output are unchanged.

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

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 simplifies the internal value/option handling for EXPLAIN by removing/flattening builder-style helper types and switching to simpler accumulation/deduping approaches, aiming to keep EXPLAIN text/JSON output unchanged.

Changes:

  • Removes ExplainOptions.Builder and updates the SQL parser to accumulate EXPLAIN options directly during parsing.
  • Simplifies region-boundary de-duping in ExplainTable#getRegionLocationsForExplainPlan by removing the RegionBoundary helper type.
  • Refactors ExplainPlanAttributes construction to use a single private builder-backed constructor.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
phoenix-core-client/src/main/java/org/apache/phoenix/parse/ExplainOptions.javaRemoves the public nested builder type used previously to construct ExplainOptions.
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/ExplainTable.javaReplaces RegionBoundary equality/hash logic with string-based boundary keys for deduping region locations.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainPlanAttributes.javaReplaces the large all-args constructor path with a private builder-backed constructor and updates build().
phoenix-core-client/src/main/antlr3/PhoenixSQL.gUpdates EXPLAIN option parsing to use an EnumSet-tracked accumulator and construct ExplainOptions directly.

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

@apurtell

Copy link
Copy Markdown
ContributorAuthor

Test Results

Unit tests (*Test)

Directly impacted EXPLAIN unit tests (3 classes, 123 tests)

ClassTestsFailuresErrorsSkippedNotes
ExplainOptionsParserTest16000Covers every EXPLAIN [(<opt>...)] form including (REGIONS, REGIONS) duplicate-rejection and the legacy WITH REGIONS alias — exercises the new EnumSet<ExplainOpt> seen path.
ExplainJsonOutputTest2000Covers EXPLAIN (REGIONS, FORMAT JSON) end-to-end JSON output — exercises getDefaultExplainPlan() (now seeded by new ExplainPlanAttributesBuilder().build()) and the regionLocations dedupe path.
ExplainPlanTest105000The connectionless EXPLAIN-grammar baseline suite. Asserts grammar/JSON shape for every operator class — exercises the new builder-driven private ExplainPlanAttributes ctor on every test.

Other unit tests touching ExplainPlanAttributes / ExplainOptions (9 classes, 315 tests)

ClassTestsFailuresErrorsSkipped
MergeSortResultIteratorTest2000
ConcatResultIteratorTest2000
JoinQueryCompilerTest2000
StatementHintsCompilationTest4000
QueryPlanTest4000
TenantSpecificViewIndexCompileTest6000
PhoenixSyncTableMapperTest28000
QueryOptimizerTest52001
QueryCompilerTest215002

Integration tests (*IT)

Directly EXPLAIN-impacted ITs (2 classes, 37 tests)

ClassTestsFailuresErrorsSkippedTimeNotes
ExplainPlanWithStatsEnabledIT3000050.8 sAsserts EXPLAIN text/JSON output across all stats-enabled call sites — primary regression guard for ExplainPlanAttributes + plan-total estimate cells.
QueryLoggerIT700047.4 sAsserts the JDBC query-logger row matches EXPLAIN output, exercising the round-trip through ExplainPlanAttributes.

Wider IT batch 1 — different EXPLAIN call sites (7 classes, 66 tests)

ClassTestsFailuresErrorsSkippedTime
ClientHashAggregateIT20003.3 s
ProjectArrayElemAfterHashJoinIT20002.5 s
DistinctPrefixFilterIT500036.8 s
UnionAllIT1900073.6 s
EmptyColumnIT7000159.4 s
TenantSpecificViewIndexIT1100019.0 s
CostBasedDecisionIT20000160.5 s

Wider IT batch 2 — joins, in-list, delete (4 classes, 370 tests)

ClassTestsFailuresErrorsSkippedTime
SortMergeJoinNoIndexIT3500013.1 s
HashJoinNoIndexIT3300015.4 s
InListIT228000145.1 s
DeleteIT74000205.6 s

@apurtell
apurtell merged commit d21ddf8 into apache:PHOENIX-7876-featureJun 14, 2026
@apurtell
apurtell deleted the PHOENIX-7923 branch June 14, 2026 06:18
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