This is an automated email from the ASF dual-hosted git repository.

apurtell pushed a commit to branch PHOENIX-7876-feature
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/PHOENIX-7876-feature by this 
push:
     new 3fe39c3a91 PHOENIX-7935 Propagate requested EXPLAIN options to nested 
plan contexts (#2544)
3fe39c3a91 is described below

commit 3fe39c3a912648a10e0e25f6d732d8d43c3387aa
Author: Andrew Purtell <[email protected]>
AuthorDate: Wed Jun 24 17:34:17 2026 -0700

    PHOENIX-7935 Propagate requested EXPLAIN options to nested plan contexts 
(#2544)
    
    Co-authored-by: Claude Opus 4.8[1m] <[email protected]>
---
 .../main/java/org/apache/phoenix/execute/ClientAggregatePlan.java  | 3 +++
 .../src/main/java/org/apache/phoenix/execute/ClientScanPlan.java   | 3 +++
 .../src/main/java/org/apache/phoenix/execute/HashJoinPlan.java     | 5 +++++
 .../main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java    | 4 ++++
 .../main/java/org/apache/phoenix/execute/TupleProjectionPlan.java  | 7 +++++++
 .../src/main/java/org/apache/phoenix/execute/UnionPlan.java        | 5 +++++
 6 files changed, 27 insertions(+)

diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
index b6b3e69219..aef8ca24ab 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
@@ -223,6 +223,9 @@ public class ClientAggregatePlan extends 
ClientProcessingPlan {
 
   @Override
   public ExplainPlan getExplainPlan() throws SQLException {
+    // Carry the requested EXPLAIN options down to the delegate so every 
participating scan renders
+    // the same disclosures (e.g. VERBOSE predicate-origin attribution) as the 
driver scan.
+    delegate.getContext().setExplainOptions(context.getExplainOptions());
     ExplainPlan explainPlan = delegate.getExplainPlan();
     List<String> planSteps = Lists.newArrayList(explainPlan.getPlanSteps());
     ExplainPlanAttributes explainPlanAttributes = 
explainPlan.getPlanStepsAsAttributes();
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientScanPlan.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientScanPlan.java
index 895853ee6a..06ea050f5f 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientScanPlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/ClientScanPlan.java
@@ -119,6 +119,9 @@ public class ClientScanPlan extends ClientProcessingPlan {
 
   @Override
   public ExplainPlan getExplainPlan() throws SQLException {
+    // Carry the requested EXPLAIN options down to the delegate so every 
participating scan renders
+    // the same disclosures (e.g. VERBOSE predicate-origin attribution) as the 
driver scan.
+    delegate.getContext().setExplainOptions(context.getExplainOptions());
     ExplainPlan explainPlan = delegate.getExplainPlan();
     List<String> currentPlanSteps = explainPlan.getPlanSteps();
     ExplainPlanAttributes explainPlanAttributes = 
explainPlan.getPlanStepsAsAttributes();
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
index 7732d4d6e7..c48b67276a 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
@@ -330,6 +330,11 @@ public class HashJoinPlan extends DelegateQueryPlan {
     ExplainPlanAttributesBuilder builder = new 
ExplainPlanAttributesBuilder(delegateAttributes);
     List<ExplainPlanAttributes> subPlanAttributes = Lists.newArrayList();
     int count = subPlans.length;
+    // Carry the requested EXPLAIN options down to each sub-plan so every 
participating scan renders
+    // the same disclosures (e.g. VERBOSE predicate-origin attribution) as the 
driver scan.
+    for (int i = 0; i < count; i++) {
+      
subPlans[i].getInnerPlan().getContext().setExplainOptions(getContext().getExplainOptions());
+    }
     for (int i = 0; i < count; i++) {
       planSteps.addAll(subPlans[i].getPreSteps(this));
       ExplainPlanAttributes subPlanAttribute = 
subPlans[i].getPreStepsAsAttributes(this);
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
index 3c769cf7bb..f0ae604516 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/SortMergeJoinPlan.java
@@ -193,6 +193,10 @@ public class SortMergeJoinPlan implements QueryPlan {
     List<String> steps = Lists.newArrayList();
     steps
       .add("SORT-MERGE-JOIN (" + joinType.toString().toUpperCase() + ") TABLES 
 /* SORT_MERGE */");
+    // Carry the requested EXPLAIN options down to both join halves so every 
participating scan
+    // renders the same disclosures (e.g. VERBOSE predicate-origin 
attribution) as the driver scan.
+    lhsPlan.getContext().setExplainOptions(getContext().getExplainOptions());
+    rhsPlan.getContext().setExplainOptions(getContext().getExplainOptions());
     ExplainPlan lhsExplainPlan = lhsPlan.getExplainPlan();
     List<String> lhsPlanSteps = lhsExplainPlan.getPlanSteps();
     ExplainPlanAttributes lhsPlanAttributes = 
lhsExplainPlan.getPlanStepsAsAttributes();
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/TupleProjectionPlan.java
 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/TupleProjectionPlan.java
index bc2e1b200f..43e565b64a 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/TupleProjectionPlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/TupleProjectionPlan.java
@@ -147,6 +147,13 @@ public class TupleProjectionPlan extends DelegateQueryPlan 
{
 
   @Override
   public ExplainPlan getExplainPlan() throws SQLException {
+    // getContext() is the delegate's context (already carrying the requested 
EXPLAIN options).
+    // Carry those same options onto the separate post-filter context so this 
plan's CLIENT FILTER
+    // BY
+    // renders the same disclosures (e.g. VERBOSE predicate-origin 
attribution) as the driver scan.
+    if (statementContext != null) {
+      statementContext.setExplainOptions(getContext().getExplainOptions());
+    }
     ExplainPlan explainPlan = delegate.getExplainPlan();
     List<String> planSteps = Lists.newArrayList(explainPlan.getPlanSteps());
     ExplainPlanAttributes explainPlanAttributes = 
explainPlan.getPlanStepsAsAttributes();
diff --git 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/UnionPlan.java 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/UnionPlan.java
index 0ff5496839..2350bfdd53 100644
--- 
a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/UnionPlan.java
+++ 
b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/UnionPlan.java
@@ -239,6 +239,11 @@ public class UnionPlan implements QueryPlan {
     String abstractExplainPlan = "UNION ALL OVER " + this.plans.size() + " 
QUERIES";
     builder.setAbstractExplainPlan(abstractExplainPlan);
     steps.add(abstractExplainPlan);
+    // Carry the requested EXPLAIN options down to each branch so every 
participating scan renders
+    // the same disclosures (e.g. VERBOSE predicate-origin attribution) as the 
driver scan.
+    for (QueryPlan plan : plans) {
+      plan.getContext().setExplainOptions(getContext().getExplainOptions());
+    }
     // Compose each branch from its own getExplainPlan() so the full sub-plan 
structure of every
     // branch is preserved and explaining the union does not trigger sub-plan 
execution.
     UnionResultIterators.explainBranches(plans, steps, builder);

Reply via email to