Skip to content

PHOENIX-7916 Disclose atomic upsert flavors and RETURNING in EXPLAIN - #2524

Merged
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7916
Jun 12, 2026
Merged

PHOENIX-7916 Disclose atomic upsert flavors and RETURNING in EXPLAIN#2524
apurtell merged 1 commit into
apache:PHOENIX-7876-featurefrom
apurtell:PHOENIX-7916

Conversation

@apurtell

Copy link
Copy Markdown
Contributor

Disclose atomic upsert flavors and RETURNING in EXPLAIN.

Replace the single opaque PUT SINGLE ROW operator line with a switch on UpsertStatement.OnDuplicateKeyType, surface the server-side update assignments under ON DUPLICATE KEY UPDATE, and disclose RETURNING * on every mutation plan whose parsed statement has isReturningRow() == true — that is, every concrete UpsertCompiler plan (UpsertValuesMutationPlan, ServerUpsertSelectMutationPlan, ClientUpsertSelectMutationPlan) and every DeleteCompiler plan (SingleRowDeleteMutationPlan, ServerSelectDeleteMutationPlan, ClientSelectDeleteMutationPlan).

Add three new structured fields to ExplainPlanAttributes and matching fluent assertions on ExplainPlanTestUtil.

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 enhances Phoenix EXPLAIN output for mutation plans by exposing previously opaque UPSERT/DELETE mutation details in both the textual plan steps and the structured ExplainPlanAttributes representation, including atomic UPSERT “ON DUPLICATE KEY” flavors, server-side update assignments, and RETURNING *.

Changes:

  • Extend ExplainPlanAttributes with mutation-operator fields (onDuplicateKeyAction, serverUpdateSet, returningRow) and wire them into explain-plan builders.
  • Update UPSERT/DELETE mutation plan explain output to disclose ON DUPLICATE KEY flavor, SERVER UPDATE SET assignments, and RETURNING * where applicable.
  • Add test utilities and new tests validating the enriched textual and structured EXPLAIN output.

Reviewed changes

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

Show a summary per file
FileDescription
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTestUtil.javaAdds fluent assertions for new mutation-specific structured explain fields.
phoenix-core/src/test/java/org/apache/phoenix/query/explain/ExplainPlanTest.javaAdds new mutation EXPLAIN tests and updates default expected attribute JSON to include new fields.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/UpsertCompiler.javaPropagates RETURNING * and ON DUPLICATE KEY details into mutation plan explain steps/attributes.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/ExplainPlanAttributes.javaIntroduces new structured fields and builder setters for mutation-operator disclosures.
phoenix-core-client/src/main/java/org/apache/phoenix/compile/DeleteCompiler.javaPropagates RETURNING * into delete mutation plan explain steps/attributes across delete plan variants.

💡 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) — all PASS

Test classTestsFailuresErrorsSkipped
ExplainPlanTest94000
QueryCompilerTest215002
QueryOptimizerTest52001
QueryPlanTest4000
StatementHintsCompilationTest4000
JoinQueryCompilerTest2000
TenantSpecificViewIndexCompileTest6000
Total377003

Integration tests (*IT) — all PASS

Test classTestsFailuresErrorsSkippedTime (s)
UpsertSelectIT54000207.4
DeleteIT74000247.6
OnDuplicateKeyIT154000465.4
GlobalIndexOptimizationIT700036.6
CostBasedDecisionIT20000176.6
OnDuplicateKey2IT2520032422.5
Total5610032

OnDuplicateKeyIT and OnDuplicateKey2IT directly exercise the rewritten atomic-upsert getExplainPlan() switch and the modified UpsertValuesMutationPlan constructor across the NONE/UPDATE/UPDATE_ONLY/IGNORE flavors. UpsertSelectIT exercises the modified ServerUpsertSelectMutationPlan / ClientUpsertSelectMutationPlan constructors. DeleteIT exercises all three modified DeleteCompiler plan constructors.

@apurtell
apurtell merged commit c21e896 into apache:PHOENIX-7876-featureJun 12, 2026
@apurtell
apurtell deleted the PHOENIX-7916 branch June 12, 2026 21:13
apurtell added a commit to apurtell/phoenix that referenced this pull request Jun 17, 2026
…pache#2524)
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
…2524)
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
…pache#2524)
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