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

csringhofer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit e67b627858bf0c404fd041709a9ce8577085ac99
Author: Steve Carlin <[email protected]>
AuthorDate: Tue Nov 18 15:59:43 2025 -0800

    IMPALA-14408: (addendum) Log Calcite exception in profile
    
    This addendum logs the exception thrown in the runtime profile
    under the CalciteFailureReason key.
    
    Testing: test_ranger.py uses this.
    
    Change-Id: Ia18a52c488f9c73d51690997b277fd8e918c645f
    Reviewed-on: http://gerrit.cloudera.org:8080/23686
    Reviewed-by: Joe McDonnell <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 fe/src/main/java/org/apache/impala/service/Frontend.java     | 12 +++++++++---
 .../apache/impala/calcite/service/ExecRequestCreator.java    |  2 +-
 tests/authorization/test_ranger.py                           | 12 +++++-------
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/service/Frontend.java 
b/fe/src/main/java/org/apache/impala/service/Frontend.java
index ee209c487..1fd38f246 100644
--- a/fe/src/main/java/org/apache/impala/service/Frontend.java
+++ b/fe/src/main/java/org/apache/impala/service/Frontend.java
@@ -299,6 +299,7 @@ public class Frontend {
   private static final String CPU_ASK_BOUNDED = "CpuAskBounded";
   private static final String AVG_ADMISSION_SLOTS_PER_EXECUTOR =
       "AvgAdmissionSlotsPerExecutor";
+  private static final String CALCITE_FAILURE_REASON = "CalciteFailureReason";
 
   // info about the planner used. In this code, we will always use the 
Original planner,
   // but other planners may set their own planner values
@@ -2396,6 +2397,7 @@ public class Frontend {
       PlanCtx planCtx, EventSequence timeline) throws ImpalaException {
     TExecRequest request = null;
     CompilerFactory compilerFactory = getCalciteCompilerFactory(planCtx);
+    String exceptionClass = null;
     if (compilerFactory != null) {
       try {
         request = getTExecRequest(compilerFactory, planCtx, timeline);
@@ -2403,7 +2405,8 @@ public class Frontend {
         if (!shouldFallbackToRegularPlanner(planCtx, e)) {
           throw e;
         }
-        LOG.info("Calcite planner failed: ", e);
+        LOG.info("Calcite planner failed: {}", e.getClass());
+        exceptionClass = e.getClass().toString();
         timeline.markEvent("Failing over from Calcite planner");
       }
     }
@@ -2414,7 +2417,7 @@ public class Frontend {
       compilerFactory = new CompilerFactoryImpl();
       request = getTExecRequest(compilerFactory, planCtx, timeline);
     }
-    addPlannerToProfile(compilerFactory.getPlannerString());
+    addPlannerToProfile(compilerFactory.getPlannerString(), exceptionClass);
     return request;
   }
 
@@ -2841,9 +2844,12 @@ public class Frontend {
     }
   }
 
-  public static void addPlannerToProfile(String planner) {
+  public static void addPlannerToProfile(String planner, String 
exceptionClass) {
     TRuntimeProfileNode profile = createTRuntimeProfileNode(PLANNER_PROFILE);
     addInfoString(profile, PLANNER_TYPE, planner);
+    if (exceptionClass != null) {
+      addInfoString(profile, CALCITE_FAILURE_REASON, exceptionClass);
+    }
     FrontendProfile.getCurrent().addChildrenProfile(profile);
   }
 
diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
index a60d0eb7a..66efff738 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
@@ -169,7 +169,7 @@ public class ExecRequestCreator implements CompilerStep {
 
     TRuntimeProfileNode calciteProfile =
         
this.queryCtx.getFrontend().createTRuntimeProfileNode(Frontend.PLANNER_PROFILE);
-    this.queryCtx.getFrontend().addPlannerToProfile("CalcitePlanner");
+    this.queryCtx.getFrontend().addPlannerToProfile("CalcitePlanner", null);
     result.setProfile(FrontendProfile.getCurrent().emitAsThrift());
     
result.setProfile_children(FrontendProfile.getCurrent().emitChildrenAsThrift());
     if (isExplain) {
diff --git a/tests/authorization/test_ranger.py 
b/tests/authorization/test_ranger.py
index fa72be612..46fbd89ce 100644
--- a/tests/authorization/test_ranger.py
+++ b/tests/authorization/test_ranger.py
@@ -1650,8 +1650,6 @@ class TestRanger(CustomClusterTestSuite):
       table_2 = "alltypestiny"
       test_select_query_1 = "select id from {0}.{1}".format(database, table_1)
       test_select_query_2 = "select id from {0}.{1}".format(database, table_2)
-      select_error = "UnsupportedFeatureException: Column masking and row 
filtering " \
-          "are not yet supported by the Calcite planner."
 
       policy_cnt = 0
       try:
@@ -1662,17 +1660,17 @@ class TestRanger(CustomClusterTestSuite):
 
         admin_client.execute("grant select (id) on table {0}.{1} to user {2}"
             .format(database, table_1, grantee_user))
-        result = self.execute_query_expect_failure(non_owner_client, 
test_select_query_1)
-        assert select_error in str(result)
+        result = self.execute_query_expect_success(non_owner_client, 
test_select_query_1)
+        assert "UnsupportedFeatureException" in str(result.runtime_profile)
 
         TestRanger._add_row_filtering_policy(
           unique_name + str(policy_cnt), grantee_user, database, table_2, "id 
% 2 = 0")
         policy_cnt += 1
 
         admin_client.execute("grant select (id) on table {0}.{1} to user {2}"
-            .format(database, table_1, grantee_user))
-        result = self.execute_query_expect_failure(non_owner_client, 
test_select_query_2)
-        assert select_error in str(result)
+            .format(database, table_2, grantee_user))
+        result = self.execute_query_expect_success(non_owner_client, 
test_select_query_2)
+        assert "UnsupportedFeatureException" in str(result.runtime_profile)
       finally:
         admin_client.execute("revoke select (id) on table {0}.{1} from user 
{2}"
             .format(database, table_1, grantee_user))

Reply via email to