You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ap...@apache.org on 2026/07/24 00:23:54 UTC

(phoenix) 21/27: PHOENIX-7927 Fix EXPLAIN plumbing related NPE in DelegateQueryPlan.setOptimizerDecision (#2532)

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

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

commit fa2f821cac913b45561ccc4347da4cfa1f98d90f
Author: Andrew Purtell <ap...@apache.org>
AuthorDate: Mon Jun 15 08:41:53 2026 -0700

    PHOENIX-7927 Fix EXPLAIN plumbing related NPE in DelegateQueryPlan.setOptimizerDecision (#2532)
    
    Co-authored-by: Claude Opus 4.8[1m] <no...@anthropic.com>
---
 .../java/org/apache/phoenix/execute/DelegateQueryPlan.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/DelegateQueryPlan.java b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/DelegateQueryPlan.java
index 3ca9b8e059..ac3616e2c0 100644
--- a/phoenix-core-client/src/main/java/org/apache/phoenix/execute/DelegateQueryPlan.java
+++ b/phoenix-core-client/src/main/java/org/apache/phoenix/execute/DelegateQueryPlan.java
@@ -39,6 +39,10 @@ import org.apache.phoenix.schema.TableRef;
 
 public abstract class DelegateQueryPlan implements QueryPlan {
   protected final QueryPlan delegate;
+  // Fallback storage for the optimizer decision used only when this plan has no delegate to
+  // forward to. Some DelegateQueryPlan subclasses intentionally pass a null delegate and override
+  // getContext()/getTableRef()/getProjector() to serve from local state.
+  private OptimizerDecision optimizerDecision;
 
   public DelegateQueryPlan(QueryPlan delegate) {
     this.delegate = delegate;
@@ -175,11 +179,15 @@ public abstract class DelegateQueryPlan implements QueryPlan {
 
   @Override
   public OptimizerDecision getOptimizerDecision() {
-    return delegate.getOptimizerDecision();
+    return delegate != null ? delegate.getOptimizerDecision() : optimizerDecision;
   }
 
   @Override
   public void setOptimizerDecision(OptimizerDecision decision) {
-    delegate.setOptimizerDecision(decision);
+    if (delegate != null) {
+      delegate.setOptimizerDecision(decision);
+    } else {
+      this.optimizerDecision = decision;
+    }
   }
 }